public void Run(Options options) { // Applying options if (!string.IsNullOrEmpty(options.GCLatencyMode)) { GCSettings.LatencyMode = Enum.Parse <GCLatencyMode>(options.GCLatencyMode); } if (options.Duration.HasValue) { BurnTester.DefaultDuration = TimeSpan.FromSeconds(options.Duration.Value); } BurnTester.DefaultMaxSize = ArgumentHelper.ParseRelativeValue( options.MaxSize, BurnTester.DefaultMaxSize, true); ParallelRunner.ThreadCount = (int)ArgumentHelper.ParseRelativeValue( options.ThreadCount, ParallelRunner.ThreadCount, true); var tests = options.Tests?.ToLowerInvariant() ?? ""; var ramSizeGb = HardwareInfo.GetRamSize() ?? 4; var staticSetSizeGb = 0; if (!string.IsNullOrEmpty(options.StaticSetSize)) { tests += "b"; staticSetSizeGb = (int)ArgumentHelper.ParseRelativeValue(options.StaticSetSize, ramSizeGb, true); } var outputMode = options.OutputMode ?? "f"; if (outputMode == "f") { // Dumping environment info Writer.AppendValue("Launch parameters", string.Join(" ", Environment.GetCommandLineArgs().Skip(1))); using (Writer.Section("Software:")) { Writer.AppendValue("Runtime", ".NET Core"); using (Writer.Indent()) { Writer.AppendValue("Version", RuntimeInformation.FrameworkDescription); Writer.AppendValue("GC mode", GCInfo.GetGCMode()); } Writer.AppendValue("OS", $"{RuntimeInformation.OSDescription.Trim()} ({RuntimeInformation.OSArchitecture})"); } using (Writer.Section("Hardware:")) { var coreCountAddon = ParallelRunner.ThreadCount != Environment.ProcessorCount ? $", {ParallelRunner.ThreadCount} used by test" : ""; Writer.AppendValue("CPU", HardwareInfo.GetCpuModelName()); Writer.AppendValue("CPU core count", $"{Environment.ProcessorCount}{coreCountAddon}"); Writer.AppendValue("RAM size", $"{ramSizeGb:N0} GB"); } Writer.AppendLine(); } RunWarmup(); if (tests == "") { RunSpeedTest(); RunBurnTest("--- Stateless server (no static set) ---", 0); RunBurnTest("--- Worker / typical server (static set = 20% RAM) ---", (long)(ramSizeGb * Sizes.GB / 5)); RunBurnTest("--- Caching / compute server (static set = 50% RAM) ---", (long)(ramSizeGb * Sizes.GB / 2)); return; } if (tests.Contains("a")) { RunSpeedTest(); } if (tests.Contains("b")) { var title = $"--- Static set = {staticSetSizeGb} GB ({staticSetSizeGb * 100.0 / ramSizeGb:0.##} % RAM) ---"; RunBurnTest(title, (long)(staticSetSizeGb * Sizes.GB)); } }
public static IndentedTextWriter AppendMetric(this IndentedTextWriter writer, string name, double?value, string unit, string format = "0.###") => writer.AppendValue(name, value.ToString(format, unit));