Skip to content

Commit 3c77472

Browse files
committed
feat(bench): add in benchmark reference to dev mapster
1 parent ce4b870 commit 3c77472

File tree

4 files changed

+52
-9
lines changed

4 files changed

+52
-9
lines changed

src/Benchmark.Development/Benchmark.Development.csproj

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
55
<TargetFramework>net10.0</TargetFramework>
6-
<CopyLocalLockFileAssemblies Condition=" '$(Configuration)'=='Debug' ">true</CopyLocalLockFileAssemblies>
6+
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
77
<ImplicitUsings>enable</ImplicitUsings>
88
<Nullable>enable</Nullable>
99
<SignAssembly>True</SignAssembly>
@@ -20,7 +20,18 @@
2020

2121
<ItemGroup>
2222
<PackageReference Include="BenchmarkDotNet" Version="0.15.8" />
23-
<PackageReference Include="Mapster" Version="$(SciVersion)" />
2423
</ItemGroup>
25-
24+
<ItemGroup Condition="'$(Configuration)'=='Debug'">
25+
<PackageReference Include="Mapster" Version="$(SciVersion)" />
26+
</ItemGroup>
27+
<ItemGroup Condition="'$(Configuration)'=='Release'">
28+
<PackageReference Include="Mapster" Version="$(SciVersion)" />
29+
</ItemGroup>
30+
<ItemGroup Condition="'$(Configuration)'=='nuget-bench'">
31+
<PackageReference Include="Mapster" Version="$(SciVersion)" />
32+
</ItemGroup>
33+
<ItemGroup Condition="'$(Configuration)'=='developer-bench'">
34+
<ProjectReference Include="..\Mapster\Mapster.csproj" />
35+
</ItemGroup>
36+
2637
</Project>

src/Benchmark.Development/Benchmarks/Config.cs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using BenchmarkDotNet.Columns;
1+
using Benchmark.Development;
2+
using BenchmarkDotNet.Columns;
23
using BenchmarkDotNet.Configs;
34
using BenchmarkDotNet.Diagnosers;
45
using BenchmarkDotNet.Exporters;
@@ -31,23 +32,28 @@ public Config()
3132

3233
AddColumn(BaselineRatioColumn.RatioMean);
3334
AddColumnProvider(DefaultColumnProviders.Metrics);
35+
3436

35-
string[] targetVersions = [
36-
"7.4.0",
37-
"9.0.0-pre01",
38-
];
3937

40-
foreach (var version in targetVersions)
38+
foreach (var version in MapsterVersion.Get())
4139
{
4240
AddJob(Job.ShortRun
4341
.WithLaunchCount(1)
4442
.WithWarmupCount(2)
4543
.WithIterationCount(10)
44+
.WithCustomBuildConfiguration("nuget-bench")
4645
.WithMsBuildArguments($"/p:SciVersion={version}")
4746
.WithId($"v{version}")
4847
);
4948
}
5049

50+
AddJob(Job.ShortRun
51+
.WithLaunchCount(1)
52+
.WithWarmupCount(2)
53+
.WithIterationCount(10)
54+
.WithCustomBuildConfiguration("developer-bench")
55+
.WithId("developer"));
56+
5157
Options |= ConfigOptions.JoinSummary;
5258
}
5359
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
namespace Benchmark.Development
2+
{
3+
internal static class MapsterVersion
4+
{
5+
6+
internal static string[] Get() =>
7+
[
8+
"7.4.0",
9+
"9.0.0-pre01"
10+
];
11+
}
12+
}

src/Mapster/Directory.Build.props

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<Project >
2+
<PropertyGroup>
3+
<!-- Properties related to benchmark builds -->
4+
<IsPackable>false</IsPackable>
5+
</PropertyGroup>
6+
<PropertyGroup Condition="'$(Configuration)'=='nuget-bench'">
7+
<Optimize>true</Optimize>
8+
<SignAssembly>false</SignAssembly>
9+
</PropertyGroup>
10+
<PropertyGroup Condition="'$(Configuration)'=='developer-bench'">
11+
<Optimize>true</Optimize>
12+
<SignAssembly>false</SignAssembly>
13+
</PropertyGroup>
14+
</Project>

0 commit comments

Comments
 (0)