Ejemplo n.º 1
0
        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());
            }
        }
Ejemplo n.º 2
0
        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());

            }
        }