Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace BenchmarkDotNet.Samples
- {
- class Program
- {
- static void Main(string[] args)
- {
- BenchmarkRunner.Run<TheTypeWithBenchmarks>(DefaultConfig.Instance.With(new SampleIntegrationWithProfiler()));
- }
- }
- public class SampleIntegrationWithProfiler : IDiagnoser
- {
- private Process profiler;
- public IEnumerable<string> Ids => new[] { nameof(SampleIntegrationWithProfiler) };
- // it tells BDN to run benchmarks once again with this diagnoser enabled, do the diagnostics and discard results (they are affected by oveerhead)
- public Diagnosers.RunMode GetRunMode(Benchmark benchmark) => Diagnosers.RunMode.ExtraRun;
- public void Handle(HostSignal signal, DiagnoserActionParameters parameters)
- {
- if (signal == HostSignal.BeforeMainRun)
- profiler = Process.Start("thePathToProfiler.exe", $"somehow tell the profiler to attach to this process {parameters.Process.Id}");
- else if (signal == HostSignal.AfterMainRun)
- profiler.Close();
- }
- public IEnumerable<IExporter> Exporters => Array.Empty<IExporter>();
- public void DisplayResults(ILogger logger) { }
- public IColumnProvider GetColumnProvider() => EmptyColumnProvider.Instance;
- public IEnumerable<ValidationError> Validate(ValidationParameters validationParameters) => Array.Empty<ValidationError>();
- public void ProcessResults(DiagnoserResults results) { }
- }
- }
Add Comment
Please, Sign In to add comment