Skip to content

Commit 0027cdc

Browse files
committed
Getting benchmarks to run
1 parent 61b7473 commit 0027cdc

8 files changed

Lines changed: 41 additions & 26 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,3 +224,5 @@ FakesAssemblies/
224224
# Uncomment if necessary however generally it will be regenerated when needed
225225
#!**/packages/repositories.config
226226
/LiteDB.BadJsonTest
227+
228+
BenchmarkDotNet.Artifacts/results/

LiteDBX.Benchmarks/Benchmarks/Deletion/DeletionBenchmark.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,14 @@ public async Task GlobalSetup()
2424
await _fileMetaCollection.EnsureIndex(file => file.ShouldBeShown);
2525
_data = FileMetaGenerator<FileMetaBase>.GenerateList(DatasetSize);
2626
}
27-
27+
2828
[IterationSetup]
29-
public async Task IterationSetup()
29+
public void IterationSetup()
30+
{
31+
IterationSetupAsync().GetAwaiter().GetResult();
32+
}
33+
34+
private async Task IterationSetupAsync()
3035
{
3136
await _fileMetaCollection.Insert(_data);
3237
await DatabaseInstance.Checkpoint();

LiteDBX.Benchmarks/Benchmarks/Insertion/InsertionBasicBenchmark.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@ public class InsertionBasicBenchmark : BenchmarkBase
1414
private ILiteCollection<FileMetaBase> _fileMetaCollection;
1515

1616
[GlobalSetup]
17-
public async Task GlobalSetup()
17+
public Task GlobalSetup()
1818
{
1919
File.Delete(DatabasePath);
2020
DatabaseInstance = new LiteDatabase(ConnectionString());
2121
_fileMetaCollection = DatabaseInstance.GetCollection<FileMetaBase>();
2222
_data = FileMetaGenerator<FileMetaBase>.GenerateList(DatasetSize);
23+
24+
return Task.CompletedTask;
2325
}
2426

2527
[Benchmark(Baseline = true)]
@@ -59,7 +61,12 @@ public async Task UpsertionWithLoop()
5961
}
6062

6163
[IterationCleanup]
62-
public async Task IterationCleanup()
64+
public void IterationCleanup()
65+
{
66+
IterationCleanupAsync().GetAwaiter().GetResult();
67+
}
68+
69+
private async Task IterationCleanupAsync()
6370
{
6471
await DatabaseInstance.DropCollection(nameof(FileMetaBase));
6572
await DatabaseInstance.Checkpoint();

LiteDBX.Benchmarks/Benchmarks/Insertion/InsertionIgnoreExpressionPropertyBenchmark.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,12 @@ public async ValueTask<int> InsertionWithBsonIgnore()
5959
}
6060

6161
[IterationCleanup]
62-
public async Task IterationCleanup()
62+
public void IterationCleanup()
63+
{
64+
IterationCleanupAsync().GetAwaiter().GetResult();
65+
}
66+
67+
private async Task IterationCleanupAsync()
6368
{
6469
var indexesCollection = DatabaseInstance.GetCollection("$indexes");
6570
var droppedCollectionIndexes = await indexesCollection.Query()

LiteDBX.Benchmarks/LiteDBX.Benchmarks.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@
33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
55
<TargetFramework>net10.0</TargetFramework>
6-
<LangVersion>8</LangVersion>
6+
<LangVersion>latest</LangVersion>
77
<RootNamespace>LiteDbX.Benchmarks</RootNamespace>
88
<AssemblyName>LiteDbX.Benchmarks</AssemblyName>
99
</PropertyGroup>
1010

1111
<ItemGroup>
12-
<PackageReference Include="BenchmarkDotNet" Version="0.13.12" />
12+
<PackageReference Include="BenchmarkDotNet" Version="0.15.8" />
1313
</ItemGroup>
1414

1515
<ItemGroup>
16-
<ProjectReference Include="..\LiteDBX\LiteDBX.csproj" />
16+
<ProjectReference Include="..\LiteDbX\LiteDbX.csproj" />
1717
</ItemGroup>
1818

1919
</Project>

LiteDBX.Benchmarks/Program.cs

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,25 @@
44
using BenchmarkDotNet.Exporters;
55
using BenchmarkDotNet.Jobs;
66
using BenchmarkDotNet.Running;
7-
using BenchmarkDotNet.Toolchains.CsProj;
87

98
namespace LiteDbX.Benchmarks
109
{
1110
internal class Program
1211
{
1312
private static void Main(string[] args)
1413
{
15-
BenchmarkRunner.Run(typeof(Program).Assembly, DefaultConfig.Instance
16-
//.With(new BenchmarkDotNet.Filters.AnyCategoriesFilter(new[] { Benchmarks.Constants.Categories.GENERAL }))
17-
//.AddFilter(new BenchmarkDotNet.Filters.AnyCategoriesFilter([Benchmarks.Constants.Categories.GENERAL]))
18-
.AddJob(Job.Default.WithRuntime(CoreRuntime.Core80)
19-
.WithJit(Jit.RyuJit)
20-
.WithToolchain(CsProjCoreToolchain.NetCoreApp80)
21-
.WithGcForce(true))
22-
/*.With(Job.Default.With(MonoRuntime.Default)
23-
.With(Jit.Llvm)
24-
.With(new[] {new MonoArgument("--optimize=inline")})
25-
.WithGcForce(true))*/
26-
.AddDiagnoser(MemoryDiagnoser.Default)
27-
.AddExporter(BenchmarkReportExporter.Default, HtmlExporter.Default, MarkdownExporter.GitHub)
28-
.KeepBenchmarkFiles());
14+
BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args, DefaultConfig.Instance
15+
//.With(new BenchmarkDotNet.Filters.AnyCategoriesFilter(new[] { Benchmarks.Constants.Categories.GENERAL }))
16+
//.AddFilter(new BenchmarkDotNet.Filters.AnyCategoriesFilter([Benchmarks.Constants.Categories.GENERAL]))
17+
.AddJob(Job.Default.WithRuntime(CoreRuntime.Core10_0)
18+
.WithJit(Jit.RyuJit)
19+
.WithGcForce(true))
20+
/*.With(Job.Default.With(MonoRuntime.Default)
21+
.With(Jit.Llvm)
22+
.With(new[] {new MonoArgument("--optimize=inline")})
23+
.WithGcForce(true))*/
24+
.AddDiagnoser(MemoryDiagnoser.Default)
25+
.KeepBenchmarkFiles());
2926
}
3027
}
3128
}

LiteDBX.slnx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Solution>
2-
<Project Path="LiteDBX.Benchmarks\LiteDBX.Benchmarks.csproj"/>
2+
<Project Path="LiteDbX.Benchmarks\LiteDbX.Benchmarks.csproj"/>
33
<Project Path="LiteDBX.Shell\LiteDBX.Shell.csproj"/>
44
<Project Path="LiteDBX.Stress\LiteDBX.Stress.csproj"/>
55
<Project Path="LiteDBX.Tests\LiteDBX.Tests.csproj"/>
6-
<Project Path="LiteDBX\LiteDBX.csproj"/>
6+
<Project Path="LiteDbX\LiteDbX.csproj"/>
77
</Solution>

LiteDBX/LiteDBX.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
<NoWarn>1701;1702;1705;1591;0618</NoWarn>
2727
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\LiteDB.xml</DocumentationFile>
2828
<SignAssembly Condition="'$(OS)'=='Windows_NT'">true</SignAssembly>
29-
<AssemblyOriginatorKeyFile Condition="'$(Configuration)' == 'Release'">LiteDB.snk</AssemblyOriginatorKeyFile>
3029
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
3130
<LangVersion>latest</LangVersion>
3231
</PropertyGroup>

0 commit comments

Comments
 (0)