public void Should_build_when_at_least_one_metric_assigned() { var counterBenchmark = new CounterBenchmarkSetting("Test", AssertionType.Total, Assertion.Empty); var gcBenchmark = new GcBenchmarkSetting(GcMetric.TotalCollections, GcGeneration.Gen2, AssertionType.Total, Assertion.Empty); var memoryBenchmark = new MemoryBenchmarkSetting(MemoryMetric.TotalBytesAllocated, Assertion.Empty); var settings = new BenchmarkSettings(TestMode.Measurement, RunMode.Iterations, 10, 1000, new List <IBenchmarkSetting>() { gcBenchmark, memoryBenchmark, counterBenchmark }, new Dictionary <MetricName, MetricsCollectorSelector>() { { gcBenchmark.MetricName, new GcCollectionsSelector() }, { counterBenchmark.MetricName, new CounterSelector() }, { memoryBenchmark.MetricName, new TotalMemorySelector() } }); var builder = new BenchmarkBuilder(settings); var run = builder.NewRun(WarmupData.PreWarmup); Assert.Equal(3, run.MeasureCount); Assert.Equal(1, run.Counters.Count); Assert.True(run.Counters.ContainsKey(counterBenchmark.CounterName)); }
public void Should_build_when_exactly_one_metric_assigned() { var counterBenchmark = new CounterBenchmarkSetting("Test", AssertionType.Total, Assertion.Empty); var settings = new BenchmarkSettings(TestMode.Measurement, RunMode.Iterations, 10, 1000, new GcBenchmarkSetting[0], new MemoryBenchmarkSetting[0], new CounterBenchmarkSetting[] { counterBenchmark }); var builder = new BenchmarkBuilder(settings); var run = builder.NewRun(WarmupData.PreWarmup); Assert.Equal(1, run.MeasureCount); Assert.Equal(1, run.Counters.Count); Assert.True(run.Counters.ContainsKey(counterBenchmark.CounterName)); }
public void Should_build_when_at_least_one_metric_assigned() { var counterBenchmark = new CounterBenchmarkSetting("Test", AssertionType.Total, Assertion.Empty); var gcBenchmark = new GcBenchmarkSetting(GcMetric.TotalCollections, GcGeneration.AllGc, AssertionType.Total, Assertion.Empty); var memoryBenchmark = new MemoryBenchmarkSetting(MemoryMetric.TotalBytesAllocated, Assertion.Empty); var settings = new BenchmarkSettings(TestMode.Measurement, RunMode.Iterations, 10, 1000, new[] { gcBenchmark }, new[] { memoryBenchmark }, new[] { counterBenchmark }); var builder = new BenchmarkBuilder(settings); var run = builder.NewRun(WarmupData.PreWarmup); Assert.Equal(2 + (SysInfo.Instance.MaxGcGeneration + 1), run.MeasureCount); Assert.Equal(1, run.Counters.Count); Assert.True(run.Counters.ContainsKey(counterBenchmark.CounterName)); }