コード例 #1
0
        public void record_data()
        {
            var spec = new Specification
            {
                name = "Some Name"
            };

            var timings = new Timings();

            timings.Start(spec);
            using (timings.Subject("Fixture.Setup", "Math"))
            {
                using (timings.Subject("Grammar", "Adding"))
                {
                    using (timings.Subject("Fixture.Teardown", "Math"))
                    {
                        Thread.Sleep(100);
                    }
                }
            }

            var records = timings.Finish();

            records.Select(x => x.Subject).ShouldHaveTheSameElementsAs("Some Name", "Math", "Adding", "Math");

            records.Each(x => x.Duration.ShouldBeGreaterThan(0));
        }
コード例 #2
0
        public SpecResults Execute(Specification specification)
        {
            var plan    = specification.CreatePlan(_library);
            var timings = new Timings();

            timings.Start(specification);

            IExecutionContext execution = null;

            using (timings.Subject("Context", "Creation"))
            {
                execution = _system.CreateContext();
            }

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

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

            var executor = new SynchronousExecutor(context);

            plan.AcceptVisitor(executor);



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

            return(context.FinalizeResults(1));
        }
コード例 #3
0
        public SpecResults Execute(Specification specification)
        {
            var plan    = specification.CreatePlan(_library);
            var timings = new Timings();

            _warmup.Wait(1.Minutes());

            timings.Start(specification);

            IExecutionContext execution = null;
            SpecContext       context   = null;

            try
            {
                using (timings.Record("Context", "Creation"))
                {
                    execution = _system.CreateContext();
                }

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

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

                SpecExecution.RunAll(context, plan);
            }
            finally
            {
                execution?.Dispose();
                context?.Dispose();
            }


            return(context.FinalizeResults(1));
        }
コード例 #4
0
        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();
            }
        }
コード例 #5
0
        public SpecResults Run(Specification specification)
        {
            var plan    = specification.CreatePlan(_running.Fixtures);
            var timings = new Timings();

            _warmup.Wait(1.Minutes());

            timings.Start(specification);

            IExecutionContext execution = null;
            SpecContext       context   = null;

            try
            {
                using (timings.Record("Context", "Creation"))
                {
                    execution = _running.System.CreateContext();
                }

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

                execution.BeforeExecution(context);

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

                SpecExecution.RunAll(context, plan);

                execution.AfterExecution(context);
            }
            finally
            {
                execution?.Dispose();
                context?.Dispose();
            }

            var results = context.FinalizeResults(1);

            _records.Add(new BatchRecord
            {
                results       = results,
                specification = specification
            });

            return(results);
        }
コード例 #6
0
        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();
            }
        }
コード例 #7
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));
        }