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; }
internal ITest CreateTest(ITestMetadata metadata) { if (metadata == null) { throw new ArgumentNullException("metadata"); } return(new Test(metadata, ProcessContext.GrinderContext)); }
internal ITest CreateTest(ITestMetadata metadata) { if (metadata == null) { throw new ArgumentNullException("metadata"); } return new Test(metadata, ProcessContext.GrinderContext); }
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)); }
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)); }
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(); }
public static void Time(ITestMetadata mapper, Action action) { Time(null, action, null, 1); }
public ITest AddTest(ITestMetadata metadata) { ITest test = CreateTest(metadata); tests.Add(test); return test; }