Example #1
0
        private void TestInvoke(BenchmarkAction benchmarkAction, int unrollFactor, bool isIdle, object expectedResult)
        {
            try
            {
                BenchmarkAllCases.Counter = 0;

                if (isIdle)
                {
                    benchmarkAction.InvokeSingle();
                    Assert.Equal(0, BenchmarkAllCases.Counter);
                    benchmarkAction.InvokeMultiple(0);
                    Assert.Equal(0, BenchmarkAllCases.Counter);
                    benchmarkAction.InvokeMultiple(11);
                    Assert.Equal(0, BenchmarkAllCases.Counter);
                }
                else
                {
                    benchmarkAction.InvokeSingle();
                    Assert.Equal(1, BenchmarkAllCases.Counter);
                    benchmarkAction.InvokeMultiple(0);
                    Assert.Equal(1, BenchmarkAllCases.Counter);
                    benchmarkAction.InvokeMultiple(11);
                    Assert.Equal(BenchmarkAllCases.Counter, 1 + unrollFactor * 11);
                }

                Assert.Equal(benchmarkAction.LastRunResult, expectedResult);
            }
            finally
            {
                BenchmarkAllCases.Counter = 0;
            }
        }
 public void Add(BenchmarkAction action,string name)
 {
     _actions.Add(new BItem(action,name));
 }
 public BItem(BenchmarkAction action,string name)
 {
     Result=new BenchmarkResult(){Name = name};
     Action = action;
 }