Created
February 9, 2018 16:54
-
-
Save adamsitnik/50a6e3cfd218887803b7dc040c260b91 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment