Skip to content

Commit 6e8428c

Browse files
committed
code cleanup
1 parent d8b3b24 commit 6e8428c

File tree

10 files changed

+513
-80
lines changed

10 files changed

+513
-80
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
**********************
2+
Windows PowerShell transcript start
3+
Start time: 20240127201954
4+
Username: COV\mus63954
5+
RunAs User: COV\mus63954
6+
Configuration Name:
7+
Machine: COV0076292 (Microsoft Windows NT 10.0.22621.0)
8+
Host Application: C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe -NoExit -Command & { Import-Module "$env:VSAPPIDDIR\..\Tools\Microsoft.VisualStudio.DevShell.dll"; Enter-VsDevShell -SkipAutomaticLocation -SetDefaultWindowTitle -InstallPath $env:VSAPPIDDIR\..\..\}
9+
Process ID: 18896
10+
PSVersion: 5.1.22621.2506
11+
PSEdition: Desktop
12+
PSCompatibleVersions: 1.0, 2.0, 3.0, 4.0, 5.0, 5.1.22621.2506
13+
BuildVersion: 10.0.22621.2506
14+
CLRVersion: 4.0.30319.42000
15+
WSManStackVersion: 3.0
16+
PSRemotingProtocolVersion: 2.3
17+
SerializationVersion: 1.1.0.1
18+
**********************
19+
PS>& { Import-Module "$env:VSAPPIDDIR\..\Tools\Microsoft.VisualStudio.DevShell.dll"; Enter-VsDevShell -SkipAutomaticLocation -SetDefaultWindowTitle -InstallPath $env:VSAPPIDDIR\..\..\}
20+
**********************************************************************
21+
** Visual Studio 2022 Developer PowerShell v17.8.3
22+
** Copyright (c) 2022 Microsoft Corporation
23+
**********************************************************************

BenchmarkDotNet.sln

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BenchmarkDotNet.Diagnostics
5151
EndProject
5252
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks", "tests\BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks\BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks.csproj", "{AACA2C63-A85B-47AB-99FC-72C3FF408B14}"
5353
EndProject
54-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BenchmarkDotNet.TestAdapter", "src\BenchmarkDotNet.TestAdapter\BenchmarkDotNet.TestAdapter.csproj", "{4C9C89B8-7C4E-4ECF-B3C9-324C8772EDAC}"
54+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BenchmarkDotNet.TestAdapter", "src\BenchmarkDotNet.TestAdapter\BenchmarkDotNet.TestAdapter.csproj", "{4C9C89B8-7C4E-4ECF-B3C9-324C8772EDAC}"
55+
EndProject
56+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Test", "Test\Test.csproj", "{EAB204A3-794D-48C7-B773-E16C3B201451}"
5557
EndProject
5658
Global
5759
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -143,6 +145,10 @@ Global
143145
{4C9C89B8-7C4E-4ECF-B3C9-324C8772EDAC}.Debug|Any CPU.Build.0 = Debug|Any CPU
144146
{4C9C89B8-7C4E-4ECF-B3C9-324C8772EDAC}.Release|Any CPU.ActiveCfg = Release|Any CPU
145147
{4C9C89B8-7C4E-4ECF-B3C9-324C8772EDAC}.Release|Any CPU.Build.0 = Release|Any CPU
148+
{EAB204A3-794D-48C7-B773-E16C3B201451}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
149+
{EAB204A3-794D-48C7-B773-E16C3B201451}.Debug|Any CPU.Build.0 = Debug|Any CPU
150+
{EAB204A3-794D-48C7-B773-E16C3B201451}.Release|Any CPU.ActiveCfg = Release|Any CPU
151+
{EAB204A3-794D-48C7-B773-E16C3B201451}.Release|Any CPU.Build.0 = Release|Any CPU
146152
EndGlobalSection
147153
GlobalSection(SolutionProperties) = preSolution
148154
HideSolutionNode = FALSE
@@ -169,6 +175,7 @@ Global
169175
{C5BDA61F-3A56-4B59-901D-0A17E78F4076} = {D6597E3A-6892-4A68-8E14-042FC941FDA2}
170176
{AACA2C63-A85B-47AB-99FC-72C3FF408B14} = {14195214-591A-45B7-851A-19D3BA2413F9}
171177
{4C9C89B8-7C4E-4ECF-B3C9-324C8772EDAC} = {D6597E3A-6892-4A68-8E14-042FC941FDA2}
178+
{EAB204A3-794D-48C7-B773-E16C3B201451} = {14195214-591A-45B7-851A-19D3BA2413F9}
172179
EndGlobalSection
173180
GlobalSection(ExtensibilityGlobals) = postSolution
174181
SolutionGuid = {4D9AF12B-1F7F-45A7-9E8C-E4E46ADCBD1F}

Test/CustomDotNetCliPathConfig.cs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
using BenchmarkDotNet.Configs;
2+
using BenchmarkDotNet.Toolchains.CsProj;
3+
using BenchmarkDotNet.Toolchains.DotNetCli;
4+
using System;
5+
using System.Collections.Generic;
6+
using System.Linq;
7+
using System.Text;
8+
using System.Threading.Tasks;
9+
using BenchmarkDotNet.Jobs;
10+
using BenchmarkDotNet.Loggers;
11+
using BenchmarkDotNet.Exporters;
12+
using BenchmarkDotNet.Columns;
13+
14+
namespace Test
15+
{
16+
public class CustomPathsConfig : ManualConfig
17+
{
18+
public CustomPathsConfig()
19+
{
20+
var dotnetCli32bit = NetCoreAppSettings
21+
.NetCoreApp20
22+
//.WithCustomDotNetCliPath(@"C:\Test\dotnet.exe", "32 bit cli");
23+
.WithCustomDotNetCliPath(@"C:\Program Files (x86)\dotnet\dotnet.exe", "32 bit cli");
24+
25+
//C:\Test
26+
27+
var dotnetCli64bit = NetCoreAppSettings
28+
.NetCoreApp20
29+
.WithCustomDotNetCliPath(@"C:\Program Files\dotnet\dotnet.exe", "64 bit cli");
30+
31+
Add(Job.RyuJitX86.With(CsProjCoreToolchain.From(dotnetCli32bit)).WithId("32 bit cli"));
32+
Add(Job.RyuJitX64.With(CsProjCoreToolchain.From(dotnetCli64bit)).WithId("64 bit cli"));
33+
34+
AddLogger(ConsoleLogger.Default);
35+
AddExporter(DefaultExporters.Csv);
36+
37+
AddColumnProvider(DefaultColumnProviders.Instance);
38+
39+
40+
41+
42+
}
43+
}
44+
}

Test/Md5VsSha256.cs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
using BenchmarkDotNet.Attributes;
2+
using BenchmarkDotNet.Engines;
3+
using BenchmarkDotNet.Jobs;
4+
using System;
5+
using System.Collections.Generic;
6+
using System.Linq;
7+
using System.Security.Cryptography;
8+
using System.Text;
9+
using System.Threading.Tasks;
10+
11+
namespace Test
12+
{
13+
//[RPlotExporter]
14+
//[AllStatisticsColumn]
15+
//[MinIterationTime(25)]
16+
//[SimpleJob(RunStrategy.ColdStart, launchCount: 5, warmupCount: 1, iterationCount: 1, id: "Job A")]
17+
//[SimpleJob(RunStrategy.Throughput, launchCount: 1, warmupCount: 1, iterationCount: 5, id: "Job B ")]
18+
[DryJob(RuntimeMoniker.Net90)]
19+
20+
public class Md5VsSha256
21+
{
22+
private System.Security.Cryptography.SHA256 sha256 = SHA256.Create();
23+
private MD5 md5 = MD5.Create();
24+
private byte[]? data;
25+
26+
[Params(1000, 10000)]
27+
public int N;
28+
29+
[GlobalSetup]
30+
public void Setup()
31+
{
32+
data = new byte[N];
33+
new Random(42).NextBytes(data);
34+
}
35+
36+
[Benchmark]
37+
public byte[] Sha256() => sha256.ComputeHash(data);
38+
39+
[Benchmark]
40+
public byte[] Md5() => md5.ComputeHash(data);
41+
}
42+
}

Test/MemoryLeakBug.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using BenchmarkDotNet.Attributes;
2+
using BenchmarkDotNet.Diagnostics.Windows.Configs;
3+
using System;
4+
using System.Collections.Generic;
5+
using System.Linq;
6+
using System.Runtime.InteropServices;
7+
using System.Text;
8+
using System.Threading.Tasks;
9+
10+
namespace Test
11+
{
12+
[KeepBenchmarkFiles]
13+
[NativeMemoryProfiler]
14+
public class MemoryLeakBug
15+
{
16+
[Benchmark]
17+
public void Run()
18+
{
19+
var pointer = Marshal.AllocHGlobal(sizeof(byte) * 1);
20+
21+
}
22+
}
23+
}

Test/Program.cs

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
using BenchmarkDotNet.Loggers;
2+
using BenchmarkDotNet.Running;
3+
using BenchmarkDotNet.Samples;
4+
using BenchmarkDotNet.Exporters;
5+
using BenchmarkDotNet.Configs;
6+
using BenchmarkDotNet.Toolchains.DotNetCli;
7+
using BenchmarkDotNet.Jobs;
8+
using BenchmarkDotNet.Attributes;
9+
using BenchmarkDotNet.Toolchains;
10+
11+
12+
using Test;
13+
using BenchmarkDotNet.Toolchains.CsProj;
14+
15+
16+
class Program
17+
{
18+
static void Main(string[] args)
19+
{
20+
//var config = ManualConfig.Create(DefaultConfig.Instance);
21+
//config.Add(HtmlExporter.Default);
22+
//BenchmarkRunner.Run<Md5VsSha256>(config);
23+
24+
//BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args);
25+
26+
//CustomPathsConfig config = new();
27+
28+
//BenchmarkRunner.Run<Md5VsSha256>(config);
29+
30+
//var config = ManualConfig.Create(DefaultConfig.Instance);
31+
32+
CustomPathsConfig config = new CustomPathsConfig();
33+
BenchmarkRunner.Run<Md5VsSha256>(config);
34+
35+
36+
37+
}
38+
39+
40+
41+
42+
43+
44+
}
45+

Test/Test.csproj

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<ProjectReference Include="..\samples\BenchmarkDotNet.Samples\BenchmarkDotNet.Samples.csproj" />
12+
<ProjectReference Include="..\src\BenchmarkDotNet\BenchmarkDotNet.csproj" />
13+
<RuntimeHostConfigurationOption Include="System.Runtime.Loader.UseRidGraph" Value="true" />
14+
</ItemGroup>
15+
16+
</Project>

0 commit comments

Comments
 (0)