From 3223c94a92050147a02482a3810860703f0c5171 Mon Sep 17 00:00:00 2001 From: Andrey Akinshin Date: Thu, 12 Mar 2020 12:24:54 +0300 Subject: [PATCH] Code cleanup --- build/CodingStyle.ruleset | 10 +++ .../BenchmarkDotNet.Samples.csproj | 1 + .../IntroCultureInfo.cs | 2 +- .../IntroCustomMonoArguments.cs | 2 +- .../IntroDisassembly.cs | 2 +- .../IntroDisassemblyRyuJit.cs | 2 +- .../IntroEventPipeProfiler.cs | 2 +- .../IntroInliningDiagnoser.cs | 3 +- .../BenchmarkDotNet.Samples/IntroOutliers.cs | 1 - .../BenchmarkDotNet.Samples/IntroRatioSD.cs | 1 - samples/BenchmarkDotNet.Samples/Program.cs | 4 +- .../Attributes/TargetedAttribute.cs | 2 +- .../BenchmarkDotNet.Annotations.csproj | 2 +- .../Jobs/RuntimeMoniker.cs | 24 ++++- .../ConcurrencyVisualizerProfilerAttribute.cs | 1 + .../Configs/EtwProfilerAttribute.cs | 1 + .../Configs/InliningDiagnoserAttribute.cs | 1 + .../Configs/TailCallDiagnoserAttribute.cs | 1 + .../EtwProfiler.cs | 2 +- .../EtwProfilerConfig.cs | 2 - .../HardwareCounters.cs | 2 - .../Tracing/BenchmarkEvent.cs | 1 - .../Tracing/NativeMemoryLogParser.cs | 4 +- .../ClrMdDisassembler.cs | 2 +- .../DataContracts.cs | 10 +-- .../Program.cs | 6 +- src/BenchmarkDotNet.Tool/Program.cs | 2 +- .../Analysers/BaselineCustomAnalyzer.cs | 2 +- .../MultimodalDistributionAnalyzer.cs | 1 - .../Analysers/OutliersAnalyser.cs | 3 +- .../Attributes/ArtifactsPathAttribute.cs | 1 - .../ConfidenceIntervalErrorColumnAttribute.cs | 1 - .../Attributes/EncodingAttribute.cs | 2 +- .../Attributes/EventPipeProfilerAttribute.cs | 2 +- .../Attributes/Mutators/OutliersAttribute.cs | 1 - .../UnicodeConsoleLoggerAttribute.cs | 2 +- src/BenchmarkDotNet/BenchmarkDotNet.csproj | 2 +- src/BenchmarkDotNet/Code/ArrayParam.cs | 2 +- src/BenchmarkDotNet/Code/CodeGenerator.cs | 2 +- src/BenchmarkDotNet/Columns/SizeUnit.cs | 2 +- .../Columns/StatisticColumn.cs | 1 - .../Configs/ConfigExtensions.cs | 10 +-- src/BenchmarkDotNet/Configs/ManualConfig.cs | 8 +- .../ConsoleArguments/CommandLineOptions.cs | 7 +- .../ConsoleArguments/ConfigParser.cs | 3 +- .../Diagnosers/EventPipeProfile.cs | 2 +- .../Disassemblers/DisassemblyDiagnoser.cs | 2 +- .../DisassemblyDiagnoserConfig.cs | 2 +- .../Disassemblers/InstructionFormatter.cs | 2 +- .../Disassemblers/LinuxDisassembler.cs | 2 +- .../Disassemblers/MonoDisassembler.cs | 4 +- src/BenchmarkDotNet/Engines/ConsoleHost.cs | 2 +- src/BenchmarkDotNet/Engines/Engine.cs | 4 +- src/BenchmarkDotNet/Engines/EngineFactory.cs | 2 +- src/BenchmarkDotNet/Engines/EngineResolver.cs | 1 - src/BenchmarkDotNet/Engines/GcStats.cs | 2 +- src/BenchmarkDotNet/Engines/ThreadingStats.cs | 4 +- .../Exporters/CompositeExporter.cs | 2 +- .../Exporters/InstructionPointerExporter.cs | 2 +- .../Exporters/Json/JsonExporterBase.cs | 2 +- .../Exporters/RPlotExporter.cs | 2 +- .../Extensions/ReflectionExtensions.cs | 1 - .../Extensions/StatisticsExtensions.cs | 14 +-- .../Helpers/ArtifactFileNameHelper.cs | 2 +- src/BenchmarkDotNet/Helpers/AsciiHelper.cs | 4 +- .../Helpers/PowerManagementHelper.cs | 2 + src/BenchmarkDotNet/Helpers/ProcessHelper.cs | 2 +- .../Helpers/SourceCodeHelper.cs | 3 + src/BenchmarkDotNet/Jobs/AccuracyMode.cs | 1 - src/BenchmarkDotNet/Jobs/Argument.cs | 2 +- src/BenchmarkDotNet/Jobs/Job.cs | 2 + src/BenchmarkDotNet/Jobs/JobExtensions.cs | 11 ++- .../Loggers/AccumulationLogger.cs | 4 +- src/BenchmarkDotNet/Loggers/ConsoleLogger.cs | 4 +- src/BenchmarkDotNet/Loggers/ILogger.cs | 4 +- src/BenchmarkDotNet/Reports/SummaryStyle.cs | 4 +- .../Running/BenchmarkConverter.cs | 4 +- .../Running/BenchmarkRunnerClean.cs | 8 +- .../Running/BenchmarkSwitcher.cs | 11 ++- .../Running/PowerManagementApplier.cs | 8 +- .../CoreRt/CoreRtToolchainBuilder.cs | 4 +- .../Toolchains/CoreRt/Generator.cs | 8 +- .../Toolchains/CoreRun/CoreRunGenerator.cs | 5 +- .../Toolchains/CoreRun/CoreRunPublisher.cs | 4 +- .../Toolchains/CsProj/CsProjGenerator.cs | 2 +- .../CustomDotNetCliToolchainBuilder.cs | 2 + .../DotNetCli/DotNetCliGenerator.cs | 2 +- .../DotNetCli/MsBuildErrorMapper.cs | 4 +- .../InProcess.Emit/InProcessEmitExecutor.cs | 5 +- .../InProcess.Emit/InProcessEmitGenerator.cs | 89 +++++++++---------- .../Toolchains/InProcess/InProcessExecutor.cs | 4 +- .../Toolchains/ToolchainExtensions.cs | 2 +- .../Validators/CompilationValidator.cs | 2 +- .../Validators/ParamsAllValuesValidator.cs | 6 +- .../BenchmarksThatUsesFileFromOutput.cs | 2 +- .../LocalCoreRtToolchainTests.cs | 2 +- .../AttributesTests.cs | 12 +-- .../BenchmarkDotNet.IntegrationTests.csproj | 1 + .../BenchmarkSwitcherTest.cs | 14 +-- .../CustomEngineTests.cs | 1 - .../Diagnosers/ProcessMetricsTests.cs | 2 +- .../EnvironmentVariablesTests.cs | 4 +- .../ExporterIOTests.cs | 1 - .../GcModeTests.cs | 4 +- .../InProcess.EmitTests/Runnable_0.cs | 4 +- .../InProcessTest.cs | 2 + .../JitRuntimeValidationTest.cs | 2 +- .../MemoryDiagnoserTests.cs | 2 +- .../ParamsTests.cs | 4 +- .../ProcessorArchitectureTest.cs | 11 ++- .../Analysers/ZeroMeasurementHelperTests.cs | 36 ++++---- .../ParamsAllValuesApprovalTests.cs | 3 - .../BenchmarkDotNet.Tests.csproj | 4 +- .../ConfigParserTests.cs | 1 - .../Configs/EnvironmentVariableTests.cs | 2 +- .../Configs/ImmutableConfigTests.cs | 4 +- .../CsProjGeneratorTests.cs | 3 +- .../Engine/EngineFactoryTests.cs | 28 +++--- .../Engine/EngineResultStageTests.cs | 1 - .../Exporters/CommonExporterApprovalTests.cs | 1 - .../FullNameProviderTests.cs | 2 - .../GenericBuilderTests.cs | 12 +-- .../Loggers/LoggerWithPrefixTests.cs | 1 - .../Mathematics/StatisticsTests.cs | 1 - .../ParameterInstanceTests.cs | 3 +- .../Reports/DisplayPrecisionManagerTests.cs | 1 - .../Reports/RatioPrecisionTests.cs | 6 +- .../Running/BenchmarkConverterTests.cs | 1 - .../RuntimeVersionDetectionTests.cs | 1 - tests/BenchmarkDotNet.Tests/SizeUnitTests.cs | 6 +- .../BenchmarkDotNet.Tests/TypeFilterTests.cs | 10 +-- 131 files changed, 310 insertions(+), 297 deletions(-) diff --git a/build/CodingStyle.ruleset b/build/CodingStyle.ruleset index 0c7f7f27d..9f5935249 100644 --- a/build/CodingStyle.ruleset +++ b/build/CodingStyle.ruleset @@ -6,6 +6,7 @@ + @@ -18,6 +19,7 @@ + @@ -37,8 +39,10 @@ + + @@ -46,6 +50,10 @@ + + + + @@ -89,6 +97,7 @@ + @@ -115,6 +124,7 @@ + diff --git a/samples/BenchmarkDotNet.Samples/BenchmarkDotNet.Samples.csproj b/samples/BenchmarkDotNet.Samples/BenchmarkDotNet.Samples.csproj index cfa469445..e17e3f83f 100644 --- a/samples/BenchmarkDotNet.Samples/BenchmarkDotNet.Samples.csproj +++ b/samples/BenchmarkDotNet.Samples/BenchmarkDotNet.Samples.csproj @@ -11,6 +11,7 @@ AnyCPU pdbonly true + $(NoWarn);CA1018;CA5351 diff --git a/samples/BenchmarkDotNet.Samples/IntroCultureInfo.cs b/samples/BenchmarkDotNet.Samples/IntroCultureInfo.cs index c2134b02e..aa44212db 100644 --- a/samples/BenchmarkDotNet.Samples/IntroCultureInfo.cs +++ b/samples/BenchmarkDotNet.Samples/IntroCultureInfo.cs @@ -17,7 +17,7 @@ namespace BenchmarkDotNet.Samples CultureInfo.NumberFormat.NumberDecimalSeparator = "@"; } } - + [Benchmark] public void Foo() => Thread.Sleep(100); } diff --git a/samples/BenchmarkDotNet.Samples/IntroCustomMonoArguments.cs b/samples/BenchmarkDotNet.Samples/IntroCustomMonoArguments.cs index af207bda3..aa775de0a 100644 --- a/samples/BenchmarkDotNet.Samples/IntroCustomMonoArguments.cs +++ b/samples/BenchmarkDotNet.Samples/IntroCustomMonoArguments.cs @@ -36,6 +36,6 @@ namespace BenchmarkDotNet.Samples ShouldGetInlined(); ShouldGetInlined(); ShouldGetInlined(); } - void ShouldGetInlined() { } + private void ShouldGetInlined() { } } } \ No newline at end of file diff --git a/samples/BenchmarkDotNet.Samples/IntroDisassembly.cs b/samples/BenchmarkDotNet.Samples/IntroDisassembly.cs index 4b35da9fa..87fd0a315 100644 --- a/samples/BenchmarkDotNet.Samples/IntroDisassembly.cs +++ b/samples/BenchmarkDotNet.Samples/IntroDisassembly.cs @@ -6,7 +6,7 @@ namespace BenchmarkDotNet.Samples [DisassemblyDiagnoser] public class IntroDisassembly { - int[] field = Enumerable.Range(0, 100).ToArray(); + private int[] field = Enumerable.Range(0, 100).ToArray(); [Benchmark] public int SumLocal() diff --git a/samples/BenchmarkDotNet.Samples/IntroDisassemblyRyuJit.cs b/samples/BenchmarkDotNet.Samples/IntroDisassemblyRyuJit.cs index de4ecaaff..0d41d2c92 100644 --- a/samples/BenchmarkDotNet.Samples/IntroDisassemblyRyuJit.cs +++ b/samples/BenchmarkDotNet.Samples/IntroDisassemblyRyuJit.cs @@ -7,7 +7,7 @@ namespace BenchmarkDotNet.Samples [RyuJitX64Job] public class IntroDisassemblyRyuJit { - int[] field = Enumerable.Range(0, 100).ToArray(); + private int[] field = Enumerable.Range(0, 100).ToArray(); [Benchmark] public int SumLocal() diff --git a/samples/BenchmarkDotNet.Samples/IntroEventPipeProfiler.cs b/samples/BenchmarkDotNet.Samples/IntroEventPipeProfiler.cs index feb6ace5a..3e754c3a4 100644 --- a/samples/BenchmarkDotNet.Samples/IntroEventPipeProfiler.cs +++ b/samples/BenchmarkDotNet.Samples/IntroEventPipeProfiler.cs @@ -2,7 +2,7 @@ using BenchmarkDotNet.Attributes; using BenchmarkDotNet.Diagnosers; -namespace BenchmarkDotNet.Samples +namespace BenchmarkDotNet.Samples { [ShortRunJob] [EventPipeProfiler(EventPipeProfile.CpuSampling)] diff --git a/samples/BenchmarkDotNet.Samples/IntroInliningDiagnoser.cs b/samples/BenchmarkDotNet.Samples/IntroInliningDiagnoser.cs index 4e1a70b2b..22f639e96 100644 --- a/samples/BenchmarkDotNet.Samples/IntroInliningDiagnoser.cs +++ b/samples/BenchmarkDotNet.Samples/IntroInliningDiagnoser.cs @@ -1,10 +1,9 @@ using BenchmarkDotNet.Attributes; -using BenchmarkDotNet.Configs; using System.Runtime.CompilerServices; namespace BenchmarkDotNet.Samples { - [Diagnostics.Windows.Configs.InliningDiagnoser(logFailuresOnly: false, allowedNamespaces: new [] { "BenchmarkDotNet.Samples" })] + [Diagnostics.Windows.Configs.InliningDiagnoser(logFailuresOnly: false, allowedNamespaces: new[] { "BenchmarkDotNet.Samples" })] public class IntroInliningDiagnoser { [Benchmark] diff --git a/samples/BenchmarkDotNet.Samples/IntroOutliers.cs b/samples/BenchmarkDotNet.Samples/IntroOutliers.cs index 18782c8b1..8a6519109 100644 --- a/samples/BenchmarkDotNet.Samples/IntroOutliers.cs +++ b/samples/BenchmarkDotNet.Samples/IntroOutliers.cs @@ -2,7 +2,6 @@ using BenchmarkDotNet.Attributes; using BenchmarkDotNet.Configs; using BenchmarkDotNet.Jobs; -using BenchmarkDotNet.Mathematics; using Perfolizer.Mathematics.OutlierDetection; namespace BenchmarkDotNet.Samples diff --git a/samples/BenchmarkDotNet.Samples/IntroRatioSD.cs b/samples/BenchmarkDotNet.Samples/IntroRatioSD.cs index 85b8e7e04..86b32f997 100644 --- a/samples/BenchmarkDotNet.Samples/IntroRatioSD.cs +++ b/samples/BenchmarkDotNet.Samples/IntroRatioSD.cs @@ -1,7 +1,6 @@ using System.Threading; using BenchmarkDotNet.Attributes; using BenchmarkDotNet.Engines; -using BenchmarkDotNet.Mathematics; using Perfolizer.Mathematics.OutlierDetection; namespace BenchmarkDotNet.Samples diff --git a/samples/BenchmarkDotNet.Samples/Program.cs b/samples/BenchmarkDotNet.Samples/Program.cs index 4c83c2ffa..71daa668b 100644 --- a/samples/BenchmarkDotNet.Samples/Program.cs +++ b/samples/BenchmarkDotNet.Samples/Program.cs @@ -2,8 +2,8 @@ namespace BenchmarkDotNet.Samples { - class Program + public class Program { - static void Main(string[] args) => BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args); + public static void Main(string[] args) => BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args); } } \ No newline at end of file diff --git a/src/BenchmarkDotNet.Annotations/Attributes/TargetedAttribute.cs b/src/BenchmarkDotNet.Annotations/Attributes/TargetedAttribute.cs index b31815969..897298ebe 100644 --- a/src/BenchmarkDotNet.Annotations/Attributes/TargetedAttribute.cs +++ b/src/BenchmarkDotNet.Annotations/Attributes/TargetedAttribute.cs @@ -16,8 +16,8 @@ namespace BenchmarkDotNet.Attributes /// public string Target { - set => Targets = string.IsNullOrEmpty(value) ? new string[0] : value.Split(','); // , is for backward compat get => throw new InvalidOperationException("Please use Targets property"); // kept to keep compiler happy "Named attribute arguments must be fields which are not readonly, static, or const, or read-write properties which are public and not static." + set => Targets = string.IsNullOrEmpty(value) ? new string[0] : value.Split(','); // , is for backward compat } public bool Match(MethodInfo method) => Targets == null || Targets.Length == 0 || Targets.Contains(method.Name); diff --git a/src/BenchmarkDotNet.Annotations/BenchmarkDotNet.Annotations.csproj b/src/BenchmarkDotNet.Annotations/BenchmarkDotNet.Annotations.csproj index 110d3487b..f96dc9370 100644 --- a/src/BenchmarkDotNet.Annotations/BenchmarkDotNet.Annotations.csproj +++ b/src/BenchmarkDotNet.Annotations/BenchmarkDotNet.Annotations.csproj @@ -3,7 +3,7 @@ Basic BenchmarkDotNet attributes that can be used to annotate your benchmarks netstandard1.0;netstandard2.0 - $(NoWarn);1701;1702;1705;1591;3005;NU1702 + $(NoWarn);1701;1702;1705;1591;3005;NU1702;CA1825 BenchmarkDotNet.Annotations BenchmarkDotNet.Annotations BenchmarkDotNet diff --git a/src/BenchmarkDotNet.Annotations/Jobs/RuntimeMoniker.cs b/src/BenchmarkDotNet.Annotations/Jobs/RuntimeMoniker.cs index f4328a462..ad70bed16 100644 --- a/src/BenchmarkDotNet.Annotations/Jobs/RuntimeMoniker.cs +++ b/src/BenchmarkDotNet.Annotations/Jobs/RuntimeMoniker.cs @@ -6,85 +6,105 @@ namespace BenchmarkDotNet.Jobs /// the same Runtime as the host Process (default setting) /// HostProcess = 0, + /// /// not recognized, possibly a new version of .NET Core /// NotRecognized, + /// /// Mono /// Mono, + /// /// .NET 4.6.1 /// Net461, + /// /// .NET 4.6.2 /// Net462, + /// /// .NET 4.7 /// Net47, + /// /// .NET 4.7.1 /// Net471, + /// /// .NET 4.7.2 /// Net472, + /// /// .NET 4.8 /// Net48, + /// /// .NET Core 2.0 /// NetCoreApp20, + /// /// .NET Core 2.1 /// NetCoreApp21, + /// /// .NET Core 2.2 /// NetCoreApp22, + /// /// .NET Core 3.0 /// NetCoreApp30, + /// /// .NET Core 3.1 /// NetCoreApp31, + /// /// .NET Core 5.0 aka ".NET 5" /// NetCoreApp50, + /// /// CoreRT compiled as netcoreapp2.0 /// CoreRt20, + /// /// CoreRT compiled as netcoreapp2.1 /// CoreRt21, + /// /// CoreRT compiled as netcoreapp2.2 /// CoreRt22, + /// /// CoreRT compiled as netcoreapp3.0 /// CoreRt30, + /// /// CoreRT compiled as netcoreapp3.1 /// CoreRt31, + /// /// CoreRT compiled as netcoreapp5.0 /// - CoreRt50, + CoreRt50 } -} +} \ No newline at end of file diff --git a/src/BenchmarkDotNet.Diagnostics.Windows/Configs/ConcurrencyVisualizerProfilerAttribute.cs b/src/BenchmarkDotNet.Diagnostics.Windows/Configs/ConcurrencyVisualizerProfilerAttribute.cs index eb6e0001b..77bf22bb6 100644 --- a/src/BenchmarkDotNet.Diagnostics.Windows/Configs/ConcurrencyVisualizerProfilerAttribute.cs +++ b/src/BenchmarkDotNet.Diagnostics.Windows/Configs/ConcurrencyVisualizerProfilerAttribute.cs @@ -5,6 +5,7 @@ using JetBrains.Annotations; namespace BenchmarkDotNet.Diagnostics.Windows.Configs { [PublicAPI] + [AttributeUsage(AttributeTargets.Class)] public class ConcurrencyVisualizerProfilerAttribute : Attribute, IConfigSource { public ConcurrencyVisualizerProfilerAttribute() => Config = ManualConfig.CreateEmpty().AddDiagnoser(new ConcurrencyVisualizerProfiler()); diff --git a/src/BenchmarkDotNet.Diagnostics.Windows/Configs/EtwProfilerAttribute.cs b/src/BenchmarkDotNet.Diagnostics.Windows/Configs/EtwProfilerAttribute.cs index e083df10a..2ee038aa7 100644 --- a/src/BenchmarkDotNet.Diagnostics.Windows/Configs/EtwProfilerAttribute.cs +++ b/src/BenchmarkDotNet.Diagnostics.Windows/Configs/EtwProfilerAttribute.cs @@ -5,6 +5,7 @@ using JetBrains.Annotations; namespace BenchmarkDotNet.Diagnostics.Windows.Configs { [PublicAPI] + [AttributeUsage(AttributeTargets.Class)] public class EtwProfilerAttribute : Attribute, IConfigSource { /// if set to true, benchmarks will be executed on more time with the profiler attached. If set to false, there will be no extra run but the results will contain overhead. True by default. diff --git a/src/BenchmarkDotNet.Diagnostics.Windows/Configs/InliningDiagnoserAttribute.cs b/src/BenchmarkDotNet.Diagnostics.Windows/Configs/InliningDiagnoserAttribute.cs index 9db162d99..0a3f4e0dc 100644 --- a/src/BenchmarkDotNet.Diagnostics.Windows/Configs/InliningDiagnoserAttribute.cs +++ b/src/BenchmarkDotNet.Diagnostics.Windows/Configs/InliningDiagnoserAttribute.cs @@ -3,6 +3,7 @@ using BenchmarkDotNet.Configs; namespace BenchmarkDotNet.Diagnostics.Windows.Configs { + [AttributeUsage(AttributeTargets.Class)] public class InliningDiagnoserAttribute : Attribute, IConfigSource { /// only the methods that failed to get inlined. True by default. diff --git a/src/BenchmarkDotNet.Diagnostics.Windows/Configs/TailCallDiagnoserAttribute.cs b/src/BenchmarkDotNet.Diagnostics.Windows/Configs/TailCallDiagnoserAttribute.cs index b1b80ff02..712da63f5 100644 --- a/src/BenchmarkDotNet.Diagnostics.Windows/Configs/TailCallDiagnoserAttribute.cs +++ b/src/BenchmarkDotNet.Diagnostics.Windows/Configs/TailCallDiagnoserAttribute.cs @@ -3,6 +3,7 @@ using System; namespace BenchmarkDotNet.Diagnostics.Windows.Configs { + [AttributeUsage(AttributeTargets.Class)] public class TailCallDiagnoserAttribute : Attribute, IConfigSource { public IConfig Config { get; } diff --git a/src/BenchmarkDotNet.Diagnostics.Windows/EtwProfiler.cs b/src/BenchmarkDotNet.Diagnostics.Windows/EtwProfiler.cs index 273d75bf6..a7c75bc12 100644 --- a/src/BenchmarkDotNet.Diagnostics.Windows/EtwProfiler.cs +++ b/src/BenchmarkDotNet.Diagnostics.Windows/EtwProfiler.cs @@ -43,7 +43,7 @@ namespace BenchmarkDotNet.Diagnostics.Windows public string ShortName => "ETW"; - public IEnumerable Ids => new [] { nameof(EtwProfiler) }; + public IEnumerable Ids => new[] { nameof(EtwProfiler) }; public IEnumerable Exporters => Array.Empty(); diff --git a/src/BenchmarkDotNet.Diagnostics.Windows/EtwProfilerConfig.cs b/src/BenchmarkDotNet.Diagnostics.Windows/EtwProfilerConfig.cs index 3d6710257..ee6ed5465 100644 --- a/src/BenchmarkDotNet.Diagnostics.Windows/EtwProfilerConfig.cs +++ b/src/BenchmarkDotNet.Diagnostics.Windows/EtwProfilerConfig.cs @@ -1,7 +1,5 @@ using System; using System.Collections.Generic; -using System.Collections.Immutable; -using System.Linq; using BenchmarkDotNet.Diagnosers; using Microsoft.Diagnostics.Tracing; using Microsoft.Diagnostics.Tracing.Parsers; diff --git a/src/BenchmarkDotNet.Diagnostics.Windows/HardwareCounters.cs b/src/BenchmarkDotNet.Diagnostics.Windows/HardwareCounters.cs index f0ae8939a..d0aeaa048 100644 --- a/src/BenchmarkDotNet.Diagnostics.Windows/HardwareCounters.cs +++ b/src/BenchmarkDotNet.Diagnostics.Windows/HardwareCounters.cs @@ -2,9 +2,7 @@ using System.Collections.Generic; using System.Linq; using BenchmarkDotNet.Diagnosers; -using BenchmarkDotNet.Jobs; using BenchmarkDotNet.Portability; -using BenchmarkDotNet.Toolchains.InProcess; using BenchmarkDotNet.Toolchains.InProcess.Emit; using BenchmarkDotNet.Validators; using Microsoft.Diagnostics.Tracing.Session; diff --git a/src/BenchmarkDotNet.Diagnostics.Windows/Tracing/BenchmarkEvent.cs b/src/BenchmarkDotNet.Diagnostics.Windows/Tracing/BenchmarkEvent.cs index b97557852..f3ee11ac9 100644 --- a/src/BenchmarkDotNet.Diagnostics.Windows/Tracing/BenchmarkEvent.cs +++ b/src/BenchmarkDotNet.Diagnostics.Windows/Tracing/BenchmarkEvent.cs @@ -1,5 +1,4 @@ using System; -using System.Diagnostics; using System.Text; using Microsoft.Diagnostics.Tracing; diff --git a/src/BenchmarkDotNet.Diagnostics.Windows/Tracing/NativeMemoryLogParser.cs b/src/BenchmarkDotNet.Diagnostics.Windows/Tracing/NativeMemoryLogParser.cs index b3cf196e1..cd5c085fc 100644 --- a/src/BenchmarkDotNet.Diagnostics.Windows/Tracing/NativeMemoryLogParser.cs +++ b/src/BenchmarkDotNet.Diagnostics.Windows/Tracing/NativeMemoryLogParser.cs @@ -1,9 +1,8 @@ using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using System.Linq; using BenchmarkDotNet.Columns; using BenchmarkDotNet.Diagnosers; -using BenchmarkDotNet.Extensions; -using BenchmarkDotNet.Helpers; using BenchmarkDotNet.Loggers; using BenchmarkDotNet.Reports; using BenchmarkDotNet.Running; @@ -13,6 +12,7 @@ using Address = System.UInt64; namespace BenchmarkDotNet.Diagnostics.Windows.Tracing { + [SuppressMessage("StyleCop.CSharp.ReadabilityRules", "SA1121:UseBuiltInTypeAlias")] public class NativeMemoryLogParser { private static readonly string LogSeparator = new string('-', 20); diff --git a/src/BenchmarkDotNet.Disassembler.x64/ClrMdDisassembler.cs b/src/BenchmarkDotNet.Disassembler.x64/ClrMdDisassembler.cs index a66429aa0..2967441ba 100644 --- a/src/BenchmarkDotNet.Disassembler.x64/ClrMdDisassembler.cs +++ b/src/BenchmarkDotNet.Disassembler.x64/ClrMdDisassembler.cs @@ -111,7 +111,7 @@ namespace BenchmarkDotNet.Disassemblers Map[] maps = settings.PrintSource ? codes.GroupBy(code => code.InstructionPointer).OrderBy(group => group.Key).Select(group => new Map() { SourceCodes = group.ToArray() }).ToArray() - : new [] { new Map() { SourceCodes = codes.ToArray() } }; + : new[] { new Map() { SourceCodes = codes.ToArray() } }; return new DisassembledMethod { diff --git a/src/BenchmarkDotNet.Disassembler.x64/DataContracts.cs b/src/BenchmarkDotNet.Disassembler.x64/DataContracts.cs index 0fba37c23..669f9811c 100644 --- a/src/BenchmarkDotNet.Disassembler.x64/DataContracts.cs +++ b/src/BenchmarkDotNet.Disassembler.x64/DataContracts.cs @@ -50,7 +50,7 @@ namespace BenchmarkDotNet.Disassemblers public string Problem { get; set; } public Map[] Maps { get; set; } - + public string CommandLine { get; set; } public static DisassembledMethod Empty(string fullSignature, ulong nativeCode, string problem) @@ -70,17 +70,17 @@ namespace BenchmarkDotNet.Disassemblers public MutablePair[] SerializedAddressToNameMapping { get; set; } public uint PointerSize { get; set; } - [XmlIgnore()] // XmlSerializer does not support dictionaries ;) + [XmlIgnore] // XmlSerializer does not support dictionaries ;) public Dictionary AddressToNameMapping => _addressToNameMapping ?? (_addressToNameMapping = SerializedAddressToNameMapping.ToDictionary(x => x.Key, x => x.Value)); - [XmlIgnore()] + [XmlIgnore] private Dictionary _addressToNameMapping; public DisassemblyResult() { - Methods = new DisassembledMethod[0]; - Errors = new string[0]; + Methods = Array.Empty(); + Errors = Array.Empty(); } // KeyValuePair is not serializable, because it has read-only properties diff --git a/src/BenchmarkDotNet.Disassembler.x64/Program.cs b/src/BenchmarkDotNet.Disassembler.x64/Program.cs index 241e532ba..aeb649ff2 100644 --- a/src/BenchmarkDotNet.Disassembler.x64/Program.cs +++ b/src/BenchmarkDotNet.Disassembler.x64/Program.cs @@ -8,14 +8,14 @@ namespace BenchmarkDotNet.Disassemblers { internal static class Program { - // the goals of the existence of this process: + // the goals of the existence of this process: // 1. attach to benchmarked process // 2. disassemble the code // 3. save it to xml file // 4. detach & shut down // // requirements: must not have any dependencies to BenchmarkDotNet itself, KISS - static void Main(string[] args) + public static void Main(string[] args) { var options = Settings.FromArgs(args); @@ -25,7 +25,7 @@ namespace BenchmarkDotNet.Disassemblers try { var methodsToExport = ClrMdDisassembler.AttachAndDisassemble(options); - + SaveToFile(methodsToExport, options.ResultsPath); } catch (OutOfMemoryException) // thrown by clrmd when pdb is missing or in invalid format diff --git a/src/BenchmarkDotNet.Tool/Program.cs b/src/BenchmarkDotNet.Tool/Program.cs index 114dc7f6d..2da94260f 100644 --- a/src/BenchmarkDotNet.Tool/Program.cs +++ b/src/BenchmarkDotNet.Tool/Program.cs @@ -13,7 +13,7 @@ namespace BenchmarkDotNet.Tool [Command( Name = "benchmark", Description = "A dotnet tool to execute benchmarks built with BenchmarkDotNet.")] - [HelpOption()] + [HelpOption] [VersionOptionFromMember(MemberName = nameof(GetVersion))] public sealed class Program { diff --git a/src/BenchmarkDotNet/Analysers/BaselineCustomAnalyzer.cs b/src/BenchmarkDotNet/Analysers/BaselineCustomAnalyzer.cs index 7ca34a97a..51663e408 100644 --- a/src/BenchmarkDotNet/Analysers/BaselineCustomAnalyzer.cs +++ b/src/BenchmarkDotNet/Analysers/BaselineCustomAnalyzer.cs @@ -20,7 +20,7 @@ namespace BenchmarkDotNet.Analysers .ToArray(); if (columns.IsEmpty()) yield break; - + var columnNames = string.Join(", ", columns); foreach (var benchmarkCase in summary.BenchmarksCases) diff --git a/src/BenchmarkDotNet/Analysers/MultimodalDistributionAnalyzer.cs b/src/BenchmarkDotNet/Analysers/MultimodalDistributionAnalyzer.cs index 5fd49214d..9adf1bf05 100644 --- a/src/BenchmarkDotNet/Analysers/MultimodalDistributionAnalyzer.cs +++ b/src/BenchmarkDotNet/Analysers/MultimodalDistributionAnalyzer.cs @@ -1,7 +1,6 @@ using System.Collections.Generic; using System.Globalization; using BenchmarkDotNet.Engines; -using BenchmarkDotNet.Mathematics; using BenchmarkDotNet.Reports; using JetBrains.Annotations; using Perfolizer.Mathematics.Multimodality; diff --git a/src/BenchmarkDotNet/Analysers/OutliersAnalyser.cs b/src/BenchmarkDotNet/Analysers/OutliersAnalyser.cs index 1e6543f56..f4f5abea7 100644 --- a/src/BenchmarkDotNet/Analysers/OutliersAnalyser.cs +++ b/src/BenchmarkDotNet/Analysers/OutliersAnalyser.cs @@ -53,6 +53,7 @@ namespace BenchmarkDotNet.Analysers /// All outliers which present in the distribution (lower and upper) /// All lower outliers /// All upper outliers + /// CultureInfo /// The message [PublicAPI, NotNull, Pure] public static string GetMessage(double[] actualOutliers, double[] allOutliers, double[] lowerOutliers, double[] upperOutliers, CultureInfo cultureInfo) @@ -83,7 +84,7 @@ namespace BenchmarkDotNet.Analysers private static string GetRangeMessage([NotNull] double[] values, CultureInfo cultureInfo) { string Format(double value) => TimeInterval.FromNanoseconds(value).ToString(cultureInfo, "N2"); - + switch (values.Length) { case 0: return null; diff --git a/src/BenchmarkDotNet/Attributes/ArtifactsPathAttribute.cs b/src/BenchmarkDotNet/Attributes/ArtifactsPathAttribute.cs index 37dd521f8..f417d31fa 100644 --- a/src/BenchmarkDotNet/Attributes/ArtifactsPathAttribute.cs +++ b/src/BenchmarkDotNet/Attributes/ArtifactsPathAttribute.cs @@ -18,4 +18,3 @@ namespace BenchmarkDotNet.Attributes } } } - diff --git a/src/BenchmarkDotNet/Attributes/Columns/ConfidenceIntervalErrorColumnAttribute.cs b/src/BenchmarkDotNet/Attributes/Columns/ConfidenceIntervalErrorColumnAttribute.cs index 56998f827..d0d1f90fa 100644 --- a/src/BenchmarkDotNet/Attributes/Columns/ConfidenceIntervalErrorColumnAttribute.cs +++ b/src/BenchmarkDotNet/Attributes/Columns/ConfidenceIntervalErrorColumnAttribute.cs @@ -1,5 +1,4 @@ using BenchmarkDotNet.Columns; -using BenchmarkDotNet.Mathematics; using JetBrains.Annotations; using Perfolizer.Mathematics.Common; diff --git a/src/BenchmarkDotNet/Attributes/EncodingAttribute.cs b/src/BenchmarkDotNet/Attributes/EncodingAttribute.cs index 68d098b81..8737c194b 100644 --- a/src/BenchmarkDotNet/Attributes/EncodingAttribute.cs +++ b/src/BenchmarkDotNet/Attributes/EncodingAttribute.cs @@ -8,7 +8,7 @@ using JetBrains.Annotations; namespace BenchmarkDotNet.Attributes { [AttributeUsage(AttributeTargets.Class | AttributeTargets.Assembly, AllowMultiple = true)] - [Obsolete] + [Obsolete("Don't use it")] public class EncodingAttribute : Attribute, IConfigSource { public IConfig Config { get; } diff --git a/src/BenchmarkDotNet/Attributes/EventPipeProfilerAttribute.cs b/src/BenchmarkDotNet/Attributes/EventPipeProfilerAttribute.cs index 0eac7fbf1..fa71f295e 100644 --- a/src/BenchmarkDotNet/Attributes/EventPipeProfilerAttribute.cs +++ b/src/BenchmarkDotNet/Attributes/EventPipeProfilerAttribute.cs @@ -2,7 +2,7 @@ using System; using BenchmarkDotNet.Configs; using BenchmarkDotNet.Diagnosers; -namespace BenchmarkDotNet.Attributes +namespace BenchmarkDotNet.Attributes { [AttributeUsage(AttributeTargets.Class)] public class EventPipeProfilerAttribute : Attribute, IConfigSource diff --git a/src/BenchmarkDotNet/Attributes/Mutators/OutliersAttribute.cs b/src/BenchmarkDotNet/Attributes/Mutators/OutliersAttribute.cs index c03654c8e..bda7eed2d 100644 --- a/src/BenchmarkDotNet/Attributes/Mutators/OutliersAttribute.cs +++ b/src/BenchmarkDotNet/Attributes/Mutators/OutliersAttribute.cs @@ -1,5 +1,4 @@ using BenchmarkDotNet.Jobs; -using BenchmarkDotNet.Mathematics; using Perfolizer.Mathematics.OutlierDetection; namespace BenchmarkDotNet.Attributes diff --git a/src/BenchmarkDotNet/Attributes/UnicodeConsoleLoggerAttribute.cs b/src/BenchmarkDotNet/Attributes/UnicodeConsoleLoggerAttribute.cs index 7ae9117d3..79fa57199 100644 --- a/src/BenchmarkDotNet/Attributes/UnicodeConsoleLoggerAttribute.cs +++ b/src/BenchmarkDotNet/Attributes/UnicodeConsoleLoggerAttribute.cs @@ -14,7 +14,7 @@ namespace BenchmarkDotNet.Attributes { Config = ManualConfig.CreateEmpty().AddLogger(ConsoleLogger.Unicode); } - + public IConfig Config { get; } } } \ No newline at end of file diff --git a/src/BenchmarkDotNet/BenchmarkDotNet.csproj b/src/BenchmarkDotNet/BenchmarkDotNet.csproj index cdad647fb..fe44b1298 100644 --- a/src/BenchmarkDotNet/BenchmarkDotNet.csproj +++ b/src/BenchmarkDotNet/BenchmarkDotNet.csproj @@ -4,7 +4,7 @@ BenchmarkDotNet netstandard2.0 true - $(NoWarn);1701;1702;1705;1591;3005;NU1702 + $(NoWarn);1701;1702;1705;1591;3005;NU1702;CS3001;CS3003 BenchmarkDotNet BenchmarkDotNet BenchmarkDotNet diff --git a/src/BenchmarkDotNet/Code/ArrayParam.cs b/src/BenchmarkDotNet/Code/ArrayParam.cs index bf765407b..131906753 100644 --- a/src/BenchmarkDotNet/Code/ArrayParam.cs +++ b/src/BenchmarkDotNet/Code/ArrayParam.cs @@ -57,7 +57,7 @@ namespace BenchmarkDotNet.Code var methodInfo = arrayParamType.GetMethod(nameof(ForPrimitives), BindingFlags.Public | BindingFlags.Static) ?? throw new InvalidOperationException($"{nameof(ForPrimitives)} not found"); - return (IParam)methodInfo.Invoke(null, new []{ array}); + return (IParam)methodInfo.Invoke(null, new[]{ array}); } } } \ No newline at end of file diff --git a/src/BenchmarkDotNet/Code/CodeGenerator.cs b/src/BenchmarkDotNet/Code/CodeGenerator.cs index 15ee0a662..7a705cb48 100644 --- a/src/BenchmarkDotNet/Code/CodeGenerator.cs +++ b/src/BenchmarkDotNet/Code/CodeGenerator.cs @@ -276,7 +276,7 @@ namespace BenchmarkDotNet.Code private static Type GetFieldType(Type argumentType, ParameterInstance argument) { // #774 we can't store Span in a field, so we store an array (which is later casted to Span when we load the arguments) - if(argumentType.IsStackOnlyWithImplicitCast(argument.Value)) + if (argumentType.IsStackOnlyWithImplicitCast(argument.Value)) return argument.Value.GetType(); return argumentType; diff --git a/src/BenchmarkDotNet/Columns/SizeUnit.cs b/src/BenchmarkDotNet/Columns/SizeUnit.cs index dfc3057a3..3f701069a 100644 --- a/src/BenchmarkDotNet/Columns/SizeUnit.cs +++ b/src/BenchmarkDotNet/Columns/SizeUnit.cs @@ -20,7 +20,7 @@ namespace BenchmarkDotNet.Columns } private const long BytesInKiloByte = 1024L; // this value MUST NOT be changed - + public SizeValue ToValue(long value = 1) => new SizeValue(value, this); [PublicAPI] public static readonly SizeUnit B = new SizeUnit("B", "Byte", 1L); diff --git a/src/BenchmarkDotNet/Columns/StatisticColumn.cs b/src/BenchmarkDotNet/Columns/StatisticColumn.cs index c4f9a3319..f3d37af8c 100644 --- a/src/BenchmarkDotNet/Columns/StatisticColumn.cs +++ b/src/BenchmarkDotNet/Columns/StatisticColumn.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Linq; using BenchmarkDotNet.Configs; -using BenchmarkDotNet.Helpers; using BenchmarkDotNet.Mathematics; using BenchmarkDotNet.Reports; using BenchmarkDotNet.Running; diff --git a/src/BenchmarkDotNet/Configs/ConfigExtensions.cs b/src/BenchmarkDotNet/Configs/ConfigExtensions.cs index c9b1c16f6..9c903566f 100644 --- a/src/BenchmarkDotNet/Configs/ConfigExtensions.cs +++ b/src/BenchmarkDotNet/Configs/ConfigExtensions.cs @@ -23,7 +23,7 @@ namespace BenchmarkDotNet.Configs [Obsolete("This method will soon be removed, please start using .AddColumn() instead.")] [EditorBrowsable(EditorBrowsableState.Never)] public static IConfig With(this IConfig config, params IColumn[] columns) => config.AddColumn(columns); [PublicAPI] public static ManualConfig AddColumn(this IConfig config, params IColumn[] columns) => config.With(m => m.AddColumn(columns)); - + [Obsolete("This method will soon be removed, please start using .AddColumnProvider() instead.")] [EditorBrowsable(EditorBrowsableState.Never)] public static IConfig With(this IConfig config, params IColumnProvider[] columnProviders) => config.AddColumnProvider(columnProviders); [PublicAPI] public static ManualConfig AddColumnProvider(this IConfig config, params IColumnProvider[] columnProviders) => config.With(m => m.AddColumnProvider(columnProviders)); @@ -74,7 +74,7 @@ namespace BenchmarkDotNet.Configs [PublicAPI] public static ManualConfig WithArtifactsPath(this IConfig config, string artifactsPath) => config.With(m => m.WithArtifactsPath(artifactsPath)); [PublicAPI] public static ManualConfig WithUnionRule(this IConfig config, ConfigUnionRule unionRule) => config.With(m => m.WithUnionRule(unionRule)); [PublicAPI] public static ManualConfig WithCultureInfo(this IConfig config, CultureInfo cultureInfo) => config.With(m => m.CultureInfo = cultureInfo); - + /// /// determines if all auto-generated files should be kept or removed after running the benchmarks /// @@ -96,17 +96,17 @@ namespace BenchmarkDotNet.Configs /// [Obsolete("This method will soon be removed, please start using .WithOptions() instead.")] [EditorBrowsable(EditorBrowsableState.Never)] public static IConfig With(this IConfig config, ConfigOptions options) => config.WithOptions(options); - + /// /// sets given option to provided value /// [PublicAPI] public static ManualConfig WithOption(this IConfig config, ConfigOptions option, bool value) => config.With(m => m.WithOption(option, value)); - + /// /// sets given options for the config /// [PublicAPI] public static ManualConfig WithOptions(this IConfig config, ConfigOptions options) => config.With(m => m.WithOptions(options)); - + [Obsolete("This method will soon be removed, please start using .AddLogicalGroupRules() instead.")] [EditorBrowsable(EditorBrowsableState.Never)] public static IConfig With(this IConfig config, params BenchmarkLogicalGroupRule[] rules) => config.AddLogicalGroupRules(rules); [PublicAPI] public static ManualConfig AddLogicalGroupRules(this IConfig config, params BenchmarkLogicalGroupRule[] rules) => config.With(c => c.AddLogicalGroupRules(rules)); diff --git a/src/BenchmarkDotNet/Configs/ManualConfig.cs b/src/BenchmarkDotNet/Configs/ManualConfig.cs index d9f4e373a..f8e54c390 100644 --- a/src/BenchmarkDotNet/Configs/ManualConfig.cs +++ b/src/BenchmarkDotNet/Configs/ManualConfig.cs @@ -54,7 +54,7 @@ namespace BenchmarkDotNet.Configs Options = Options.Set(value, option); return this; } - + public ManualConfig WithOptions(ConfigOptions options) { Options |= options; @@ -168,7 +168,7 @@ namespace BenchmarkDotNet.Configs [EditorBrowsable(EditorBrowsableState.Never)] [Obsolete("This method will soon be removed, please start using ..AddHardwareCounters()() instead.")] public void Add(params HardwareCounter[] newHardwareCounters) => AddHardwareCounters(newHardwareCounters); - + public ManualConfig AddHardwareCounters(params HardwareCounter[] newHardwareCounters) { hardwareCounters.AddRange(newHardwareCounters); @@ -178,7 +178,7 @@ namespace BenchmarkDotNet.Configs [EditorBrowsable(EditorBrowsableState.Never)] [Obsolete("This method will soon be removed, please start using .AddFilter() instead.")] public void Add(params IFilter[] newFilters) => AddFilter(newFilters); - + public ManualConfig AddFilter(params IFilter[] newFilters) { filters.AddRange(newFilters); @@ -188,7 +188,7 @@ namespace BenchmarkDotNet.Configs [EditorBrowsable(EditorBrowsableState.Never)] [Obsolete("This method will soon be removed, please start using .AddLogicalGroupRules() instead.")] public void Add(params BenchmarkLogicalGroupRule[] rules) => AddLogicalGroupRules(rules); - + public ManualConfig AddLogicalGroupRules(params BenchmarkLogicalGroupRule[] rules) { logicalGroupRules.AddRange(rules); diff --git a/src/BenchmarkDotNet/ConsoleArguments/CommandLineOptions.cs b/src/BenchmarkDotNet/ConsoleArguments/CommandLineOptions.cs index 85d2c3d0a..a5ce016b2 100644 --- a/src/BenchmarkDotNet/ConsoleArguments/CommandLineOptions.cs +++ b/src/BenchmarkDotNet/ConsoleArguments/CommandLineOptions.cs @@ -6,7 +6,6 @@ using BenchmarkDotNet.ConsoleArguments.ListBenchmarks; using BenchmarkDotNet.Diagnosers; using BenchmarkDotNet.Engines; using BenchmarkDotNet.Helpers; -using BenchmarkDotNet.Mathematics; using CommandLine; using CommandLine.Text; using JetBrains.Annotations; @@ -182,7 +181,7 @@ namespace BenchmarkDotNet.ConsoleArguments yield return new Example("Run benchmarks for .NET Core 2.0, .NET Core 2.1 and .NET Core 2.2. .NET Core 2.0 will be baseline because it was first.", longName, new CommandLineOptions { Runtimes = new[] { "netcoreapp2.0", "netcoreapp2.1", "netcoreapp2.2" } }); yield return new Example("Use MemoryDiagnoser to get GC stats", shortName, new CommandLineOptions { UseMemoryDiagnoser = true }); yield return new Example("Use DisassemblyDiagnoser to get disassembly", shortName, new CommandLineOptions { UseDisassemblyDiagnoser = true }); - yield return new Example("Use HardwareCountersDiagnoser to get hardware counter info", longName, new CommandLineOptions { HardwareCounters = new [] { nameof(HardwareCounter.CacheMisses), nameof(HardwareCounter.InstructionRetired) } }); + yield return new Example("Use HardwareCountersDiagnoser to get hardware counter info", longName, new CommandLineOptions { HardwareCounters = new[] { nameof(HardwareCounter.CacheMisses), nameof(HardwareCounter.InstructionRetired) } }); yield return new Example("Run all benchmarks exactly once", shortName, new CommandLineOptions { BaseJob = "Dry", Filters = new[] { Escape("*") } }); yield return new Example("Run all benchmarks from System.Memory namespace", shortName, new CommandLineOptions { Filters = new[] { Escape("System.Memory*") } }); yield return new Example("Run all benchmarks from ClassA and ClassB using type names", shortName, new CommandLineOptions { Filters = new[] { "ClassA", "ClassB" } }); @@ -192,8 +191,8 @@ namespace BenchmarkDotNet.ConsoleArguments yield return new Example("Run selected benchmarks 100 times per iteration. Perform single warmup iteration and 5 actual workload iterations", longName, new CommandLineOptions { InvocationCount = 100, WarmupIterationCount = 1, IterationCount = 5}); yield return new Example("Run selected benchmarks 250ms per iteration. Perform from 9 to 15 iterations", longName, new CommandLineOptions { IterationTimeInMilliseconds = 250, MinIterationCount = 9, MaxIterationCount = 15}); yield return new Example("Run MannWhitney test with relative ratio of 5% for all benchmarks for .NET Core 2.0 (base) vs .NET Core 2.1 (diff). .NET Core 2.0 will be baseline because it was provided as first.", longName, - new CommandLineOptions { Filters = new [] { "*"}, Runtimes = new[] { "netcoreapp2.0", "netcoreapp2.1" }, StatisticalTestThreshold = "5%" }); - yield return new Example("Run benchmarks using environment variables 'ENV_VAR_KEY_1' with value 'value_1' and 'ENV_VAR_KEY_2' with value 'value_2'", longName, + new CommandLineOptions { Filters = new[] { "*"}, Runtimes = new[] { "netcoreapp2.0", "netcoreapp2.1" }, StatisticalTestThreshold = "5%" }); + yield return new Example("Run benchmarks using environment variables 'ENV_VAR_KEY_1' with value 'value_1' and 'ENV_VAR_KEY_2' with value 'value_2'", longName, new CommandLineOptions { EnvironmentVariables = new[] { "ENV_VAR_KEY_1:value_1", "ENV_VAR_KEY_2:value_2" } }); } } diff --git a/src/BenchmarkDotNet/ConsoleArguments/ConfigParser.cs b/src/BenchmarkDotNet/ConsoleArguments/ConfigParser.cs index c2718b8c6..0cd5b5ace 100644 --- a/src/BenchmarkDotNet/ConsoleArguments/ConfigParser.cs +++ b/src/BenchmarkDotNet/ConsoleArguments/ConfigParser.cs @@ -15,7 +15,6 @@ using BenchmarkDotNet.Extensions; using BenchmarkDotNet.Filters; using BenchmarkDotNet.Jobs; using BenchmarkDotNet.Loggers; -using BenchmarkDotNet.Mathematics; using BenchmarkDotNet.Portability; using BenchmarkDotNet.Reports; using BenchmarkDotNet.Toolchains.CoreRt; @@ -270,7 +269,7 @@ namespace BenchmarkDotNet.ConsoleArguments { baseJob = baseJob.WithEnvironmentVariables(options.EnvironmentVariables.Select(text => { - var separated = text.Split(new [] { EnvVarKeyValueSeparator }, 2); + var separated = text.Split(new[] { EnvVarKeyValueSeparator }, 2); return new EnvironmentVariable(separated[0], separated[1]); }).ToArray()); } diff --git a/src/BenchmarkDotNet/Diagnosers/EventPipeProfile.cs b/src/BenchmarkDotNet/Diagnosers/EventPipeProfile.cs index ba637d6ed..8f22a6f6d 100644 --- a/src/BenchmarkDotNet/Diagnosers/EventPipeProfile.cs +++ b/src/BenchmarkDotNet/Diagnosers/EventPipeProfile.cs @@ -1,4 +1,4 @@ -namespace BenchmarkDotNet.Diagnosers +namespace BenchmarkDotNet.Diagnosers { public enum EventPipeProfile { diff --git a/src/BenchmarkDotNet/Disassemblers/DisassemblyDiagnoser.cs b/src/BenchmarkDotNet/Disassemblers/DisassemblyDiagnoser.cs index 4da6af3ea..747ae1689 100644 --- a/src/BenchmarkDotNet/Disassemblers/DisassemblyDiagnoser.cs +++ b/src/BenchmarkDotNet/Disassemblers/DisassemblyDiagnoser.cs @@ -131,7 +131,7 @@ namespace BenchmarkDotNet.Diagnosers private static bool ShouldUseWindowsDisassembler(BenchmarkCase benchmarkCase) => !(benchmarkCase.Job.Environment.Runtime is MonoRuntime) && RuntimeInformation.IsWindows(); - + private static bool ShouldUseLinuxDisassembler(BenchmarkCase benchmarkCase) => !(benchmarkCase.Job.Environment.Runtime is MonoRuntime) && RuntimeInformation.IsLinux(); diff --git a/src/BenchmarkDotNet/Disassemblers/DisassemblyDiagnoserConfig.cs b/src/BenchmarkDotNet/Disassemblers/DisassemblyDiagnoserConfig.cs index 45b848839..c646ae1ed 100644 --- a/src/BenchmarkDotNet/Disassemblers/DisassemblyDiagnoserConfig.cs +++ b/src/BenchmarkDotNet/Disassemblers/DisassemblyDiagnoserConfig.cs @@ -62,7 +62,7 @@ namespace BenchmarkDotNet.Diagnosers { var symbolSolver = new SymbolResolver(addressToNameMapping); - switch(Formatter) + switch (Formatter) { case MasmFormatter masmFormatter: return new MasmFormatter(masmFormatter.MasmOptions, symbolSolver); diff --git a/src/BenchmarkDotNet/Disassemblers/InstructionFormatter.cs b/src/BenchmarkDotNet/Disassemblers/InstructionFormatter.cs index 05c99e6d3..3570e73c2 100644 --- a/src/BenchmarkDotNet/Disassemblers/InstructionFormatter.cs +++ b/src/BenchmarkDotNet/Disassemblers/InstructionFormatter.cs @@ -7,7 +7,7 @@ namespace BenchmarkDotNet.Disassemblers { internal static string Format(SourceCode sourceCode, Formatter formatter, bool printInstructionAddresses, uint pointerSize) { - switch(sourceCode) + switch (sourceCode) { case Asm asm: return InstructionFormatter.Format(asm.Instruction, formatter, printInstructionAddresses, pointerSize); diff --git a/src/BenchmarkDotNet/Disassemblers/LinuxDisassembler.cs b/src/BenchmarkDotNet/Disassemblers/LinuxDisassembler.cs index 66b118cbd..ee6cdc6cb 100644 --- a/src/BenchmarkDotNet/Disassemblers/LinuxDisassembler.cs +++ b/src/BenchmarkDotNet/Disassemblers/LinuxDisassembler.cs @@ -8,7 +8,7 @@ namespace BenchmarkDotNet.Disassemblers internal LinuxDisassembler(DisassemblyDiagnoserConfig config) => this.config = config; - internal DisassemblyResult Disassemble(DiagnoserActionParameters parameters) + internal DisassemblyResult Disassemble(DiagnoserActionParameters parameters) => ClrMdDisassembler.AttachAndDisassemble(BuildDisassemblerSettings(parameters)); private Settings BuildDisassemblerSettings(DiagnoserActionParameters parameters) diff --git a/src/BenchmarkDotNet/Disassemblers/MonoDisassembler.cs b/src/BenchmarkDotNet/Disassemblers/MonoDisassembler.cs index 5d7ae642e..75868a9ca 100644 --- a/src/BenchmarkDotNet/Disassemblers/MonoDisassembler.cs +++ b/src/BenchmarkDotNet/Disassemblers/MonoDisassembler.cs @@ -125,8 +125,8 @@ namespace BenchmarkDotNet.Disassemblers }; } - //line example 1: 0: 48 83 ec 28 sub $0x28,%rsp - //line example 2: 0000000000000000 subq $0x28, %rsp + //line example 1: 0: 48 83 ec 28 sub $0x28,%rsp + //line example 2: 0000000000000000 subq $0x28, %rsp private static readonly Regex InstructionRegex = new Regex(@"\s*(?
[0-9a-f]+)(\:\s+([0-9a-f]{2}\s+)+)?\s+(?.*)\s*", RegexOptions.Compiled); private static bool TryParseInstruction(string line, out MonoCode instruction) diff --git a/src/BenchmarkDotNet/Engines/ConsoleHost.cs b/src/BenchmarkDotNet/Engines/ConsoleHost.cs index a4107193f..918e2af72 100644 --- a/src/BenchmarkDotNet/Engines/ConsoleHost.cs +++ b/src/BenchmarkDotNet/Engines/ConsoleHost.cs @@ -30,7 +30,7 @@ namespace BenchmarkDotNet.Engines // I did not use Mutexes because they are not supported for Linux/MacOs for .NET Core // this solution is stupid simple and it works string acknowledgment = inReader.ReadLine(); - if(acknowledgment != Engine.Signals.Acknowledgment) + if (acknowledgment != Engine.Signals.Acknowledgment) throw new NotSupportedException($"Unknown Acknowledgment: {acknowledgment}"); } diff --git a/src/BenchmarkDotNet/Engines/Engine.cs b/src/BenchmarkDotNet/Engines/Engine.cs index 427171263..7ba21a490 100644 --- a/src/BenchmarkDotNet/Engines/Engine.cs +++ b/src/BenchmarkDotNet/Engines/Engine.cs @@ -148,7 +148,7 @@ namespace BenchmarkDotNet.Engines bool isOverhead = data.IterationMode == IterationMode.Overhead; var action = isOverhead ? OverheadAction : WorkloadAction; - if(!isOverhead) + if (!isOverhead) IterationSetupAction(); GcCollect(); @@ -164,7 +164,7 @@ namespace BenchmarkDotNet.Engines if (EngineEventSource.Log.IsEnabled()) EngineEventSource.Log.IterationStop(data.IterationMode, data.IterationStage, totalOperations); - if(!isOverhead) + if (!isOverhead) IterationCleanupAction(); GcCollect(); diff --git a/src/BenchmarkDotNet/Engines/EngineFactory.cs b/src/BenchmarkDotNet/Engines/EngineFactory.cs index d63081cec..f15c21fac 100644 --- a/src/BenchmarkDotNet/Engines/EngineFactory.cs +++ b/src/BenchmarkDotNet/Engines/EngineFactory.cs @@ -22,7 +22,7 @@ namespace BenchmarkDotNet.Engines throw new ArgumentNullException(nameof(engineParameters.OverheadActionNoUnroll)); if (engineParameters.OverheadActionUnroll == null) throw new ArgumentNullException(nameof(engineParameters.OverheadActionUnroll)); - if(engineParameters.TargetJob == null) + if (engineParameters.TargetJob == null) throw new ArgumentNullException(nameof(engineParameters.TargetJob)); engineParameters.GlobalSetupAction?.Invoke(); // whatever the settings are, we MUST call global setup here, the global cleanup is part of Engine's Dispose diff --git a/src/BenchmarkDotNet/Engines/EngineResolver.cs b/src/BenchmarkDotNet/Engines/EngineResolver.cs index c6d079c04..9f042e003 100644 --- a/src/BenchmarkDotNet/Engines/EngineResolver.cs +++ b/src/BenchmarkDotNet/Engines/EngineResolver.cs @@ -1,7 +1,6 @@ using System; using BenchmarkDotNet.Characteristics; using BenchmarkDotNet.Jobs; -using BenchmarkDotNet.Mathematics; using Perfolizer.Horology; using Perfolizer.Mathematics.OutlierDetection; diff --git a/src/BenchmarkDotNet/Engines/GcStats.cs b/src/BenchmarkDotNet/Engines/GcStats.cs index 5cd500e89..b30a56727 100644 --- a/src/BenchmarkDotNet/Engines/GcStats.cs +++ b/src/BenchmarkDotNet/Engines/GcStats.cs @@ -175,7 +175,7 @@ namespace BenchmarkDotNet.Engines public static GcStats Parse(string line) { - if(!line.StartsWith(ResultsLinePrefix)) + if (!line.StartsWith(ResultsLinePrefix)) throw new NotSupportedException($"Line must start with {ResultsLinePrefix}"); var measurementSplit = line.Remove(0, ResultsLinePrefix.Length).Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); diff --git a/src/BenchmarkDotNet/Engines/ThreadingStats.cs b/src/BenchmarkDotNet/Engines/ThreadingStats.cs index 0e265e16c..d196577b7 100644 --- a/src/BenchmarkDotNet/Engines/ThreadingStats.cs +++ b/src/BenchmarkDotNet/Engines/ThreadingStats.cs @@ -8,8 +8,8 @@ namespace BenchmarkDotNet.Engines internal const string ResultsLinePrefix = "Threading: "; // BDN targets .NET Standard 2.0, these properties are not part of .NET Standard 2.0, were added in .NET Core 3.0 - private static readonly Func GetCompletedWorkItemCountDelegate = CreateGetterDelegate(typeof(ThreadPool), "CompletedWorkItemCount"); - private static readonly Func GetLockContentionCountDelegate = CreateGetterDelegate(typeof(Monitor), "LockContentionCount"); + private static readonly Func GetCompletedWorkItemCountDelegate = CreateGetterDelegate(typeof(ThreadPool), nameof(CompletedWorkItemCount)); + private static readonly Func GetLockContentionCountDelegate = CreateGetterDelegate(typeof(Monitor), nameof(LockContentionCount)); public static ThreadingStats Empty => new ThreadingStats(0, 0, 0); diff --git a/src/BenchmarkDotNet/Exporters/CompositeExporter.cs b/src/BenchmarkDotNet/Exporters/CompositeExporter.cs index 360c26851..57b1bd866 100644 --- a/src/BenchmarkDotNet/Exporters/CompositeExporter.cs +++ b/src/BenchmarkDotNet/Exporters/CompositeExporter.cs @@ -17,7 +17,7 @@ namespace BenchmarkDotNet.Exporters public void ExportToLog(Summary summary, ILogger logger) { - if(summary.GetColumns().IsNullOrEmpty()) + if (summary.GetColumns().IsNullOrEmpty()) logger.WriteLineHint("You haven't configured any columns, your results will be empty"); foreach (var exporter in exporters) diff --git a/src/BenchmarkDotNet/Exporters/InstructionPointerExporter.cs b/src/BenchmarkDotNet/Exporters/InstructionPointerExporter.cs index e9b12df0c..862041827 100644 --- a/src/BenchmarkDotNet/Exporters/InstructionPointerExporter.cs +++ b/src/BenchmarkDotNet/Exporters/InstructionPointerExporter.cs @@ -175,7 +175,7 @@ namespace BenchmarkDotNet.Exporters logger.WriteLine(""); logger.WriteLine("