本文整理匯總了C#中Benchmark.AddComponent方法的典型用法代碼示例。如果您正苦於以下問題:C# Benchmark.AddComponent方法的具體用法?C# Benchmark.AddComponent怎麽用?C# Benchmark.AddComponent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Benchmark
的用法示例。
在下文中一共展示了Benchmark.AddComponent方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: SmokeTest
public void SmokeTest()
{
var target = new Benchmark();
target.Duration = TimeSpan.FromSeconds(2);
target.Threads = 4;
target.AddComponent("Commands", RandomSleep(10, 50));
target.AddComponent("Queries", RandomSleep(2,5), 10);
BenchmarkResult result = target.Run();
Trace.WriteLine("Elapsed: " + result.Elapsed);
var stats = result.StatisticsByKey();
stats.Add("Totals", result.TotalStatistics());
foreach (var stat in stats)
{
Trace.WriteLine(stat.Key);
if (stat.Key != "Totals") Trace.WriteLine("Weight: " + result.Weights[stat.Key]);
Trace.WriteLine("count : " + stat.Value.Count);
Trace.WriteLine("sum : " + stat.Value.Sum);
Trace.WriteLine("avg : " + stat.Value.MeanAverage);
Trace.WriteLine("min : " + stat.Value.Min);
Trace.WriteLine("max : " + stat.Value.Max);
Trace.WriteLine("TPS : " + stat.Value.Count / result.Elapsed.TotalSeconds);
Trace.WriteLine("Percentiles: ");
foreach (var p in new[]{10,20,30,40,50,60,70,80,90,99})
{
var percentile = stat.Value.Percentile(p);
Trace.WriteLine( p + "\t" + percentile);
}
Trace.WriteLine("");
Trace.Write("Histogram: ");
foreach (var count in stat.Value.Histogram(10))
{
Trace.Write(count + ", ");
}
Trace.WriteLine("");
Assert.AreEqual(stat.Value.Count, stat.Value.Histogram(10).Sum());
Assert.AreEqual(stat.Value.Count, stat.Value.Histogram(20).Sum());
Assert.AreEqual(stat.Value.Count, stat.Value.Histogram(30).Sum());
}
}