Exemplo n.º 1
0
 public BenchmarkRun(IReadOnlyList<MeasureBucket> measures, IReadOnlyList<Counter> counters, IBenchmarkTrace trace)
 {
     Contract.Requires(measures != null);
     Contract.Requires(counters != null);
     Measures = measures;
     MeasureCount = measures.Count;
     Counters = counters.ToDictionary(key => key.Name, v => v);
     Context = new BenchmarkContext(Counters, trace);
 }
Exemplo n.º 2
0
        public static CarFollowingSim CreateCarFollowingSim(IBenchmarkTrace trace, int distance,
                                                            int junctionsX, int junctionsY, int carCount, int maxCarCount, float generatorProbability)
        {
            PrintBenchmarkInfoIfNeeded <CarFollowingSim>(trace, distance,
                                                         junctionsX, junctionsY, carCount, maxCarCount, generatorProbability);

            CarFollowingSim sim = new CarFollowingSim(RandomSeed);

            sim.GenerateNew(distance, junctionsX, junctionsY, carCount, maxCarCount, generatorProbability, RandomSeed);

            for (int i = 0; i < WarmupStepCount; i++)
            {
                sim.DoStepReference();
            }

            return(sim);
        }
Exemplo n.º 3
0
        private static void PrintBenchmarkInfoIfNeeded <T>(IBenchmarkTrace trace, int distance,
                                                           int junctionsX, int junctionsY, int carCount, int maxCarCount, float generatorProbability) where T : SimulationBase
        {
            if (lastSimType == typeof(T) && lastDistance == distance &&
                lastJunctionsX == junctionsX && lastJunctionsY == junctionsY &&
                lastCarCount == carCount && lastMaxCarCount == maxCarCount &&
                lastGeneratorProbability == generatorProbability)
            {
                return;
            }

            lastSimType              = typeof(T);
            lastDistance             = distance;
            lastJunctionsX           = junctionsX;
            lastJunctionsY           = junctionsY;
            lastCarCount             = carCount;
            lastMaxCarCount          = maxCarCount;
            lastGeneratorProbability = generatorProbability;

            trace.Info("");

            if (typeof(T) == typeof(CellBasedSim))
            {
                trace.Info("Generating cell-based simulation...");
            }
            else if (typeof(T) == typeof(CarFollowingSim))
            {
                trace.Info("Generating car following simulation...");
            }
            else
            {
                trace.Info("Generating unknown simulation...");
            }

            trace.Info("- Distance: " + distance);
            trace.Info("- Junctions: " + junctionsX + " x " + junctionsY);
            trace.Info("- Car Count: " + carCount + " / " + maxCarCount);
            trace.Info("- Probability: " + generatorProbability);
            trace.Info("");
            trace.Info("- Warmup Step Count: " + WarmupStepCount);
            trace.Info("- Run Step Count: " + RunStepCount);
            trace.Info("- Benchmark Iterations: " + BenchmarkIterations);
            trace.Info("- Random Seed: " + RandomSeed);
            trace.Info("");
        }
        public BenchmarkSettings(TestMode testMode, RunMode runMode, int numberOfIterations, int runTimeMilliseconds,
                                 IEnumerable <IBenchmarkSetting> benchmarkSettings,
                                 IReadOnlyDictionary <MetricName, MetricsCollectorSelector> collectors, string description, string skip, IBenchmarkTrace trace, bool concurrencyModeEnabled = false)
        {
            TestMode           = testMode;
            RunMode            = runMode;
            NumberOfIterations = numberOfIterations;
            RunTime            = TimeSpan.FromMilliseconds(runTimeMilliseconds == 0 ? DefaultRuntimeMilliseconds : runTimeMilliseconds);
            Description        = description;
            Skip = skip;

            // screen line for line duplicates that made it in by accident
            Measurements = new HashSet <IBenchmarkSetting>(benchmarkSettings).ToList();

            // now filter terms that measure the same quantities, but with different BenchmarkAssertions
            // because we only want to collect those measurements ONCE, but use them across mulitple BenchmarkAssertions.
            DistinctMeasurements = Measurements.Distinct(Comparer).ToList();

            Collectors = collectors;

            Trace          = trace;
            ConcurrentMode = concurrencyModeEnabled;
        }
Exemplo n.º 5
0
 public void Setup(BenchmarkContext context)
 {
     counter = context.GetCounter("MyCounter");
     trace   = context.Trace;
 }
Exemplo n.º 6
0
 public BenchmarkContext(IReadOnlyDictionary<CounterMetricName, Counter> counters, IBenchmarkTrace trace)
 {
     Trace = trace;
     _counters = counters.ToDictionary(k => k.Key.CounterName, v => v.Value);
 }
Exemplo n.º 7
0
 public BenchmarkContext(IReadOnlyDictionary <CounterMetricName, Counter> counters, IBenchmarkTrace trace)
 {
     Trace     = trace;
     _counters = counters.ToDictionary(k => k.Key.CounterName, v => v.Value);
 }
Exemplo n.º 8
0
 public BenchmarkRun(IReadOnlyList <MeasureBucket> measures, IReadOnlyList <Counter> counters, IBenchmarkTrace trace)
 {
     Contract.Requires(measures != null);
     Contract.Requires(counters != null);
     Measures     = measures;
     MeasureCount = measures.Count;
     Counters     = counters.ToDictionary(key => key.Name, v => v);
     Context      = new BenchmarkContext(Counters, trace);
 }