Пример #1
0
 public void Jitting()
 {
     // first signal about jitting is raised from auto-generated Program.cs, look at BenchmarkProgram.txt
     Dummy1Action.Invoke();
     MainAction.Invoke(1);
     Dummy2Action.Invoke();
     IdleAction.Invoke(1);
     Dummy3Action.Invoke();
     isJitted = true;
 }
Пример #2
0
        public void Compare_String_Match()
        {
            //Arrange
            IAction obj     = new Dummy1Action(0);
            var     counter = 0;
            var     sw      = new Stopwatch();

            //Act
            sw.Start();
            for (int i = 0; i < iterations; i++)
            {
                if (obj.Type == nameof(Dummy1Action))
                {
                    ++counter;
                }
            }
            sw.Stop();

            //Assert
            Trace.WriteLine($"Compare_String_Match: Elapsed={sw.Elapsed}");
            Assert.IsTrue(true);
        }
Пример #3
0
        public void Compare_TypeWithGetType()
        {
            //Arrange
            IAction obj     = new Dummy1Action(0);
            var     counter = 0;
            var     sw      = new Stopwatch();

            //Act
            sw.Start();
            for (int i = 0; i < iterations; i++)
            {
                if (obj.GetType() == typeof(Dummy1Action))
                {
                    var c1 = (Dummy1Action)obj;
                    counter += c1.Value;
                }
            }
            sw.Stop();

            //Assert
            Trace.WriteLine($"Compare_TypeWithCast: Elapsed={sw.Elapsed}");
            Assert.IsTrue(true);
        }
Пример #4
0
        public void Compare_TypeWithAs()
        {
            //Arrange
            IAction obj   = new Dummy1Action(0);
            var     dummy = 0;
            var     sw    = new Stopwatch();

            //Act
            sw.Start();
            for (int i = 0; i < iterations; i++)
            {
                var c1 = obj as Dummy1Action;
                if (c1 != null)
                {
                    dummy += c1.Value;
                }
            }
            sw.Stop();

            //Assert
            Trace.WriteLine($"Compare_TypeWithAs: Elapsed={sw.Elapsed}");
            Assert.IsTrue(true);
        }