Beispiel #1
0
 public override void Run(BenchmarkParams benchParams)
 {
     base.Run(benchParams);
     timerBase.Interval = benchParams.TickInterval;
     timerBase.Tick    += delegate { CheckIn(); };
     timerBase.Start();
 }
Beispiel #2
0
 public override void Run(BenchmarkParams benchParams)
 {
     base.Run(benchParams);
     timer.Interval = TimeSpan.FromMilliseconds(benchParams.TickInterval);
     timer.Tick    += delegate { CheckIn(); };
     timer.Start();
 }
Beispiel #3
0
 public override void Run(BenchmarkParams benchParams)
 {
     base.Run(benchParams);
     timer.Interval = benchParams.TickInterval;
     timer.Tick    += CheckIn;
     timer.Start();
 }
Beispiel #4
0
        public override void Run(BenchmarkParams benchParams)
        {
            base.Run(benchParams);
            timer.Interval = benchParams.TickInterval;
            var syncContext = System.Threading.SynchronizationContext.Current;

            timer.Elapsed += delegate { syncContext.Post(CheckInPost, null); };
            timer.Start();
        }
Beispiel #5
0
        /// <summary>
        /// Starts benchmarking the timer.
        /// </summary>
        /// <param name="benchParams">The parameters of the benchmark.</param>
        public virtual void Run(BenchmarkParams benchParams)
        {
            if (Running)
            {
                throw new InvalidOperationException("Cannot run two benchmarks simultaneously.");
            }

            RunTime = benchParams.RunTime;
            Running = true;
            Stopwatch.Restart();
            Ticks.Clear();
        }
Beispiel #6
0
        public override void Run(BenchmarkParams benchParams)
        {
            base.Run(benchParams);
            var syncContext = System.Threading.SynchronizationContext.Current;

            System.Threading.TimerCallback method = state =>
            {
                syncContext.Post(CheckInPost, null);
            };
            timer = new System.Threading.Timer(method, null, benchParams.TickInterval, benchParams.TickInterval);
            // Starts automatically.
        }
Beispiel #7
0
        /// <summary>
        /// Start the benchmarking asynchronously.
        /// </summary>
        public void RunAsync(BenchmarkParams benchParams)
        {
            this.benchParams = benchParams;
            // Find and instantiate all benchmark types, then add them to the benchmarking sequence.
            var types = Assembly.GetExecutingAssembly().GetTypes().Where(t => t.IsSubclassOf(typeof(TimerBenchmarkerBase)));

            foreach (var type in types)
            {
                benchmarkerStack.Push((TimerBenchmarkerBase)Activator.CreateInstance(type));
            }

            RunBenchmarker(benchmarkerStack.Pop());
        }