public void run_with_non_zero_threshold_that_is_not_exceeded()
        {
            using (var timings = new Timings())
            {
                timings.Start(new Specification());

                var record = timings.Subject("something", "else", 100);
                timings.End(record);

                timings.Finish();

                record.PerfViolation.ShouldBeFalse();
            }
        }
        public void run_with_zero_threshold()
        {
            using (var timings = new Timings())
            {
                timings.Start(new Specification());

                var record = timings.Subject("something", "else", 0);

                Thread.Sleep(100);

                timings.End(record);

                timings.Finish();

                record.PerfViolation.ShouldBeFalse();
            }
        }
Пример #3
0
        public SpecResults Execute(Specification specification)
        {
            var plan    = specification.CreatePlan(_library);
            var timings = new Timings();

            timings.Start(specification);

            IExecutionContext execution = null;

            var record = timings.Subject("Context", "Creation", 0);

            try
            {
                execution = _system.CreateContext();
            }
            finally
            {
                timings.End(record);
            }

            var context = new SpecContext(specification, timings, new NulloResultObserver(), StopConditions,
                                          execution);

            context.Reporting.As <Reporting>().StartDebugListening();

            var gatherer = new LineStepGatherer(context);

            plan.AcceptVisitor(gatherer);

            foreach (var line in gatherer.Lines)
            {
                line.Execute(context);
            }

            execution.Dispose();
            context.Dispose();

            return(context.FinalizeResults(1));
        }
Пример #4
0
        public void LogResult <T>(T result, PerfRecord record) where T : IResultMessage
        {
            if (_latched)
            {
                return;
            }

            if (record != null)
            {
                Timings.End(record, result);
            }

            if (result.id.IsEmpty())
            {
                throw new ArgumentOutOfRangeException(nameof(result), "The id of the result cannot be empty");
            }

            result.spec = Specification.id;

            _resultObserver.Handle(result);
            result.Tabulate(Counts);
            Results.Add(result);
        }