示例#1
0
 private static IDiagnoser[] LoadMono()
 => new IDiagnoser[]
 {
     // this method should return a IHardwareCountersDiagnoser when we implement Hardware Counters for Unix
     MemoryDiagnoser.Default,
     DisassemblyDiagnoser.Create(new DisassemblyDiagnoserConfig()),
 };
示例#2
0
        private static IDiagnoser[] LoadClassic()
        {
            try
            {
                var benchmarkDotNetCoreAssembly = typeof(DefaultConfig).GetTypeInfo().Assembly;

                var diagnosticsAssembly = LoadDiagnosticsAssembly(benchmarkDotNetCoreAssembly);

                if (diagnosticsAssembly.GetName().Version != benchmarkDotNetCoreAssembly.GetName().Version)
                {
                    var errorMsg =
                        $"Unable to load: {DiagnosticAssemblyFileName} version {diagnosticsAssembly.GetName().Version}" +
                        Environment.NewLine +
                        $"Does not match: {System.IO.Path.GetFileName(benchmarkDotNetCoreAssembly.Location)} version {benchmarkDotNetCoreAssembly.GetName().Version}";
                    ConsoleLogger.Default.WriteLineError(errorMsg);
                }
                else
                {
                    return(new[]
                    {
                        MemoryDiagnoser.Default,
                        DisassemblyDiagnoser.Create(new DisassemblyDiagnoserConfig()),
                        CreateDiagnoser(diagnosticsAssembly, "BenchmarkDotNet.Diagnostics.Windows.InliningDiagnoser"),
                        CreateDiagnoser(diagnosticsAssembly, "BenchmarkDotNet.Diagnostics.Windows.PmcDiagnoser"),
                    });
                }
            }
            catch (Exception ex) // we're loading a plug-in, better to be safe rather than sorry
            {
                ConsoleLogger.Default.WriteLineError($"Error loading {DiagnosticAssemblyFileName}: {ex.GetType().Name} - {ex.Message}");
            }

            return(new IDiagnoser[]
            {
                MemoryDiagnoser.Default,
                DisassemblyDiagnoser.Create(new DisassemblyDiagnoserConfig())
            });
        }