本文整理汇总了C#中ITest.DoTest方法的典型用法代码示例。如果您正苦于以下问题:C# ITest.DoTest方法的具体用法?C# ITest.DoTest怎么用?C# ITest.DoTest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITest
的用法示例。
在下文中一共展示了ITest.DoTest方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RunTest
protected static void RunTest(ITest test)
{
int loops = Calibrate(test, TimeSpan.FromMilliseconds(1000));
var sw = new Stopwatch();
GC.Collect();
GC.WaitForPendingFinalizers();
var c1 = GC.CollectionCount(0);
var c2 = GC.CollectionCount(1);
var c3 = GC.CollectionCount(2);
sw.Start();
test.DoTest(loops);
sw.Stop();
c1 = GC.CollectionCount(0) - c1;
c2 = GC.CollectionCount(1) - c2;
c3 = GC.CollectionCount(2) - c3;
var lps = (int)(loops / (sw.ElapsedMilliseconds / 1000.0));
Console.WriteLine("{0,-40} {1,20} loops/s, collections {2}/{3}/{4}",
test.GetType().Name, lps,
c1, c2, c3);
}
示例2: Calibrate
static int Calibrate(ITest test, TimeSpan time)
{
int loops = 4;
var sw = new Stopwatch();
test.DoTest(1);
while (true)
{
sw.Restart();
test.DoTest(loops);
sw.Stop();
if (sw.ElapsedMilliseconds > 250)
break;
checked
{
if (sw.ElapsedMilliseconds <= 1)
loops *= 128;
else if (sw.ElapsedMilliseconds <= 10)
loops *= 16;
else
loops *= 2;
}
}
var lps = loops / (sw.ElapsedMilliseconds / 1000.0);
var totalLoops = (int)(lps * time.TotalSeconds);
if (totalLoops == 0)
totalLoops = 1;
return totalLoops;
}