public void ElapsedTimeTaskHandler_Duration()
        {
            var task = new Task(() => Thread.Sleep(TimeSpan.FromSeconds(0.5)));

            var handler = new ElapsedTimeTaskHandler();

            handler.SetNext(task);


            var result = handler.Run(new ExecutionContext());

            Assert.That(result.Duration.Ticks > 0);
        }
示例#2
0
        public void MeasureMap_Worker_ElapsedTime()
        {
            int i       = 0;
            var task    = new Task(() => i++);
            var handler = new ElapsedTimeTaskHandler();

            handler.SetNext(task);

            var worker = new Worker();
            var result = worker.Run(handler, new ProfilerSettings {
                Iterations = 10
            });

            Assert.That(result.AverageTicks > 0);
            Assert.That(result.AverageTime.Ticks > 0);
            Assert.That(result.TotalTime.Ticks > 0);

            Assert.That(result.TotalTime > result.AverageTime);
        }