示例#1
0
        public ITest AddTest(ITestMetadata metadata)
        {
            ITest test = CreateTest(metadata);

            tests.Add(test);
            return(test);
        }
        public TestReport([NotNull] ITestMetadata test, [NotNull] ITestResults results)
        {
            Assert.ArgumentNotNull(test, nameof(test));
            Assert.ArgumentNotNull(results, nameof(results));

            Owner    = test;
            _Results = results;
        }
示例#3
0
        internal ITest CreateTest(ITestMetadata metadata)
        {
            if (metadata == null)
            {
                throw new ArgumentNullException("metadata");
            }

            return(new Test(metadata, ProcessContext.GrinderContext));
        }
示例#4
0
        internal ITest CreateTest(ITestMetadata metadata)
        {
            if (metadata == null)
            {
                throw new ArgumentNullException("metadata");
            }

            return new Test(metadata, ProcessContext.GrinderContext);
        }
示例#5
0
        public Test(ITestMetadata metadata, IGrinderContext grinderContext)
        {
            if (metadata == null)
            {
                throw new ArgumentNullException("metadata");
            }

            if (grinderContext == null)
            {
                throw new ArgumentNullException("grinderContext");
            }

            Metadata = metadata;
            GrinderContext = grinderContext;
            Underlying = grinderContext.CreateTest(metadata.TestNumber, metadata.TestDescription, new TestActionWrapper(metadata.TestAction));
        }
示例#6
0
        public Test(ITestMetadata metadata, IGrinderContext grinderContext)
        {
            if (metadata == null)
            {
                throw new ArgumentNullException("metadata");
            }

            if (grinderContext == null)
            {
                throw new ArgumentNullException("grinderContext");
            }

            Metadata       = metadata;
            GrinderContext = grinderContext;
            Underlying     = grinderContext.CreateTest(metadata.TestNumber, metadata.TestDescription, new TestActionWrapper(metadata.TestAction));
        }
示例#7
0
        public static void Time(
            ITestMetadata mapper, Action action, List <Record> records, params int[] iterations)
        {
            if (mapper == null)
            {
                return;
            }

            // 1.
            var currentForeColor = Console.ForegroundColor;

            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine(mapper.Name);
            var record = new Record {
                Mapper = mapper, Iterations = new List <IterationRecord>()
            };

            foreach (var iteration in iterations)
            {
                // 2.
                GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced);
                var gcCounts = new int[GC.MaxGeneration + 1];
                for (var i = 0; i <= GC.MaxGeneration; i++)
                {
                    gcCounts[i] = GC.CollectionCount(i);
                }
                // 3.
                var watch = new Stopwatch();
                watch.Reset();
                watch.Start();
                var cycleCount = GetCycleCount();
                for (var i = 0; i < iteration; i++)
                {
                    action();
                }
                var cpuCycles = GetCycleCount() - cycleCount;
                watch.Stop();
                if (mapper != null)
                {
                    record.Iterations.Add(new IterationRecord
                    {
                        Iteration   = iteration, CPUCycles = cpuCycles,
                        TimeElapsed = watch.ElapsedMilliseconds
                    });
                }
                // 4.
                // Console.ForegroundColor = currentForeColor;
                // Console.WriteLine("\tTime Elapsed:\t" + watch.ElapsedMilliseconds.ToString("N0") + "ms");
                //  Console.WriteLine("\tCPU Cycles:\t" + cpuCycles.ToString("N0"));
                Console.Title = mapper.Name + "   " + iteration + "/" +
                                iterations[iterations.Length - 1];

                // 5.
                for (var i = 0; i <= GC.MaxGeneration; i++)
                {
                    var count = GC.CollectionCount(i) - gcCounts[i];
                    // Console.WriteLine("\tGen " + i + ": \t\t" + count);
                }
            }
            records.Add(record);
            Console.WriteLine();
        }
示例#8
0
 public static void Time(ITestMetadata mapper, Action action)
 {
     Time(null, action, null, 1);
 }
示例#9
0
 public ITest AddTest(ITestMetadata metadata)
 {
     ITest test = CreateTest(metadata);
     tests.Add(test);
     return test;
 }