本文整理汇总了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());
}
}