private static IDiagnoser[] LoadDiagnosers() { #if CLASSIC return(RuntimeInformation.IsMono() ? LoadMono() : LoadClassic()); #else return(LoadCore()); #endif }
private static IDisposable GetAssemblyResolveHelper(IToolchain toolchain, ILogger logger) { #if CLASSIC if (!(toolchain is InProcessToolchain) && // we don't want to mess with assembly loading when running benchmarks in the same process (could produce wrong results) !RuntimeInformation.IsMono()) // so far it was never an issue for Mono { return(Helpers.DirtyAssemblyResolveHelper.Create(logger)); } #endif return(null); }
private void EnableMonitoring() { #if CLASSIC if (RuntimeInformation.IsMono()) // Monitoring is not available in Mono, see http://stackoverflow.com/questions/40234948/how-to-get-the-number-of-allocated-bytes-in-mono { return; } AppDomain.MonitoringIsEnabled = true; #endif }
public override bool IsSupported(Benchmark benchmark, ILogger logger, IResolver resolver) { if (!base.IsSupported(benchmark, logger, resolver)) { return(false); } if (RuntimeInformation.IsMono()) { logger.WriteLineError($"BenchmarkDotNet does not support running .NET Core benchmarks when host process is Mono, benchmark '{benchmark.DisplayInfo}' will not be executed"); return(false); } if (string.IsNullOrEmpty(CustomDotNetCliPath) && !HostEnvironmentInfo.GetCurrent().IsDotNetCliInstalled()) { logger.WriteLineError($"BenchmarkDotNet requires dotnet cli toolchain to be installed, benchmark '{benchmark.DisplayInfo}' will not be executed"); return(false); } if (!string.IsNullOrEmpty(CustomDotNetCliPath) && !File.Exists(CustomDotNetCliPath)) { logger.WriteLineError($"Povided custom dotnet cli path does not exist, benchmark '{benchmark.DisplayInfo}' will not be executed"); return(false); } if (benchmark.Job.HasValue(EnvMode.JitCharacteristic) && benchmark.Job.ResolveValue(EnvMode.JitCharacteristic, resolver) == Jit.LegacyJit) { logger.WriteLineError($"Currently dotnet cli toolchain supports only RyuJit, benchmark '{benchmark.DisplayInfo}' will not be executed"); return(false); } if (benchmark.Job.ResolveValue(GcMode.CpuGroupsCharacteristic, resolver)) { logger.WriteLineError($"Currently project.json does not support CpuGroups (app.config does), benchmark '{benchmark.DisplayInfo}' will not be executed"); return(false); } if (benchmark.Job.ResolveValue(GcMode.AllowVeryLargeObjectsCharacteristic, resolver)) { logger.WriteLineError($"Currently project.json does not support gcAllowVeryLargeObjects (app.config does), benchmark '{benchmark.DisplayInfo}' will not be executed"); return(false); } #if NETCOREAPP1_1 if (benchmark.Job.HasValue(InfrastructureMode.EnvironmentVariablesCharacteristic)) { logger.WriteLineError($"ProcessStartInfo.EnvironmentVariables is avaialable for .NET Core 2.0, benchmark '{benchmark.DisplayInfo}' will not be executed"); return(false); } #endif return(true); }
internal DisassemblyResult Disassemble(Benchmark benchmark, MonoRuntime mono) { Debug.Assert(mono == null || !RuntimeInformation.IsMono(), "Must never be called for Non-Mono benchmarks"); var monoMethodName = GetMethodName(benchmark.Target); var output = ProcessHelper.RunAndReadOutputLineByLine( mono?.CustomPath ?? "mono", "-v -v -v -v " + $"--compile {monoMethodName} " + (benchmark.Job.Env.Jit == Jit.Llvm ? "--llvm" : "--nollvm") + $" \"{benchmark.Target.Type.GetTypeInfo().Assembly.Location}\""); return(OutputParser.Parse(output, monoMethodName, benchmark.Target.Method.Name)); }
private void EnableMonitoring() { if (!IsDiagnoserAttached) // it could affect the results, we do this in separate, diagnostics-only run { return; } #if CLASSIC if (RuntimeInformation.IsMono()) // Monitoring is not available in Mono, see http://stackoverflow.com/questions/40234948/how-to-get-the-number-of-allocated-bytes-in-mono { return; } AppDomain.MonitoringIsEnabled = true; #endif }
private static long GetAllocatedBytes(bool isDiagnosticsEnabled) { if (!isDiagnosticsEnabled || RuntimeInformation.IsMono()) // Monitoring is not available in Mono, see http://stackoverflow.com/questions/40234948/how-to-get-the-number-of-allocated-bytes- { return(0); } // "This instance Int64 property returns the number of bytes that have been allocated by a specific // AppDomain. The number is accurate as of the last garbage collection." - CLR via C# // so we enforce GC.Collect here just to make sure we get accurate results GC.Collect(); #if CORE return(getAllocatedBytesForCurrentThread.Invoke()); #elif CLASSIC return(AppDomain.CurrentDomain.MonitoringTotalAllocatedMemorySize); #endif }
internal DisassemblyResult Disassemble(Benchmark benchmark, MonoRuntime mono) { Debug.Assert(mono == null || !RuntimeInformation.IsMono(), "Must never be called for Non-Mono benchmarks"); var benchmarkTarget = benchmark.Target; string fqnMethod = GetMethodName(benchmarkTarget); string exePath = benchmarkTarget.Type.GetTypeInfo().Assembly.Location; var environmentVariables = new Dictionary <string, string> { ["MONO_VERBOSE_METHOD"] = fqnMethod }; string monoPath = mono?.CustomPath ?? "mono"; string arguments = $"--compile {fqnMethod} {exePath}"; var output = ProcessHelper.RunAndReadOutputLineByLine(monoPath, arguments, environmentVariables); string commandLine = $"{GetEnvironmentVariables(environmentVariables)} {monoPath} {arguments}"; return(OutputParser.Parse(output, benchmarkTarget.Method.Name, commandLine)); }
public override bool IsSupported(Benchmark benchmark, ILogger logger, IResolver resolver) { if (!base.IsSupported(benchmark, logger, resolver)) { return(false); } if (RuntimeInformation.IsMono()) { logger.WriteLineError($"BenchmarkDotNet does not support running .NET Core benchmarks when host process is Mono, benchmark '{benchmark.DisplayInfo}' will not be executed"); return(false); } if (!HostEnvironmentInfo.GetCurrent().IsDotNetCliInstalled()) { logger.WriteLineError($"BenchmarkDotNet requires dotnet cli toolchain to be installed, benchmark '{benchmark.DisplayInfo}' will not be executed"); return(false); } if (benchmark.Job.HasValue(EnvMode.PlatformCharacteristic) && benchmark.Job.ResolveValue(EnvMode.PlatformCharacteristic, resolver) == Platform.X86) { logger.WriteLineError($"Currently dotnet cli toolchain supports only X64 compilation, benchmark '{benchmark.DisplayInfo}' will not be executed"); return(false); } if (benchmark.Job.HasValue(EnvMode.JitCharacteristic) && benchmark.Job.ResolveValue(EnvMode.JitCharacteristic, resolver) == Jit.LegacyJit) { logger.WriteLineError($"Currently dotnet cli toolchain supports only RyuJit, benchmark '{benchmark.DisplayInfo}' will not be executed"); return(false); } if (benchmark.Job.ResolveValue(GcMode.CpuGroupsCharacteristic, resolver)) { logger.WriteLineError($"Currently project.json does not support CpuGroups (app.config does), benchmark '{benchmark.DisplayInfo}' will not be executed"); return(false); } if (benchmark.Job.ResolveValue(GcMode.AllowVeryLargeObjectsCharacteristic, resolver)) { logger.WriteLineError($"Currently project.json does not support gcAllowVeryLargeObjects (app.config does), benchmark '{benchmark.DisplayInfo}' will not be executed"); return(false); } return(true); }
public static bool IsMono() => RuntimeInformation.IsMono();
public bool IsAvailable(Summary summary) => !RuntimeInformation.IsMono() || results.Keys.Any(benchmark => !(benchmark.Job.Env.Runtime is MonoRuntime));
private bool ShouldUseMonoDisassembler(Benchmark benchmark) => benchmark.Job.Env.Runtime is MonoRuntime || RuntimeInformation.IsMono();