Guest User

Untitled

a guest
Feb 22nd, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. namespace BenchmarkDotNet.Samples
  2. {
  3. class Program
  4. {
  5. static void Main(string[] args)
  6. {
  7. BenchmarkRunner.Run<TheTypeWithBenchmarks>(DefaultConfig.Instance.With(new SampleIntegrationWithProfiler()));
  8. }
  9. }
  10.  
  11. public class SampleIntegrationWithProfiler : IDiagnoser
  12. {
  13. private Process profiler;
  14.  
  15. public IEnumerable<string> Ids => new[] { nameof(SampleIntegrationWithProfiler) };
  16.  
  17. // it tells BDN to run benchmarks once again with this diagnoser enabled, do the diagnostics and discard results (they are affected by oveerhead)
  18. public Diagnosers.RunMode GetRunMode(Benchmark benchmark) => Diagnosers.RunMode.ExtraRun;
  19.  
  20. public void Handle(HostSignal signal, DiagnoserActionParameters parameters)
  21. {
  22. if (signal == HostSignal.BeforeMainRun)
  23. profiler = Process.Start("thePathToProfiler.exe", $"somehow tell the profiler to attach to this process {parameters.Process.Id}");
  24. else if (signal == HostSignal.AfterMainRun)
  25. profiler.Close();
  26. }
  27.  
  28. public IEnumerable<IExporter> Exporters => Array.Empty<IExporter>();
  29. public void DisplayResults(ILogger logger) { }
  30. public IColumnProvider GetColumnProvider() => EmptyColumnProvider.Instance;
  31. public IEnumerable<ValidationError> Validate(ValidationParameters validationParameters) => Array.Empty<ValidationError>();
  32. public void ProcessResults(DiagnoserResults results) { }
  33. }
  34. }
Add Comment
Please, Sign In to add comment