public override void Run(BenchmarkParams benchParams) { base.Run(benchParams); timerBase.Interval = benchParams.TickInterval; timerBase.Tick += delegate { CheckIn(); }; timerBase.Start(); }
public override void Run(BenchmarkParams benchParams) { base.Run(benchParams); timer.Interval = TimeSpan.FromMilliseconds(benchParams.TickInterval); timer.Tick += delegate { CheckIn(); }; timer.Start(); }
public override void Run(BenchmarkParams benchParams) { base.Run(benchParams); timer.Interval = benchParams.TickInterval; timer.Tick += CheckIn; timer.Start(); }
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(); }
/// <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(); }
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. }
/// <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()); }