Reformat / cleanup
All checks were successful
NuGet Publish / build-and-pack (push) Successful in 46s
NuGet Publish / publish-to-gitea (push) Successful in 56s

This commit is contained in:
Joseph Doherty
2026-02-21 08:10:36 -05:00
parent 4c6aaa5a3f
commit a70d8befae
176 changed files with 50555 additions and 49587 deletions

View File

@@ -1,12 +1,8 @@
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Jobs;
using ZB.MOM.WW.CBDD.Bson;
using ZB.MOM.WW.CBDD.Core;
using ZB.MOM.WW.CBDD.Core.Collections;
using ZB.MOM.WW.CBDD.Core.Storage;
using ZB.MOM.WW.CBDD.Core.Transactions;
using System.IO;
namespace ZB.MOM.WW.CBDD.Tests.Benchmark;
@@ -19,24 +15,24 @@ namespace ZB.MOM.WW.CBDD.Tests.Benchmark;
public class ReadBenchmarks
{
private const int DocCount = 1000;
private DocumentCollection<Person> _collection = null!;
private string _docDbPath = null!;
private string _docDbWalPath = null!;
private StorageEngine _storage = null!;
private BenchmarkTransactionHolder _transactionHolder = null!;
private DocumentCollection<Person> _collection = null!;
private ObjectId[] _ids = null!;
private StorageEngine _storage = null!;
private ObjectId _targetId;
private BenchmarkTransactionHolder _transactionHolder = null!;
/// <summary>
/// Tests setup.
/// Tests setup.
/// </summary>
[GlobalSetup]
public void Setup()
{
var temp = AppContext.BaseDirectory;
string temp = AppContext.BaseDirectory;
var id = Guid.NewGuid().ToString("N");
_docDbPath = Path.Combine(temp, $"bench_read_docdb_{id}.db");
_docDbWalPath = Path.ChangeExtension(_docDbPath, ".wal");
@@ -49,18 +45,19 @@ public class ReadBenchmarks
_collection = new DocumentCollection<Person>(_storage, _transactionHolder, new PersonMapper());
_ids = new ObjectId[DocCount];
for (int i = 0; i < DocCount; i++)
for (var i = 0; i < DocCount; i++)
{
var p = CreatePerson(i);
_ids[i] = _collection.Insert(p);
}
_transactionHolder.CommitAndReset();
_targetId = _ids[DocCount / 2];
}
/// <summary>
/// Tests cleanup.
/// Tests cleanup.
/// </summary>
[GlobalCleanup]
public void Cleanup()
@@ -79,7 +76,7 @@ public class ReadBenchmarks
Id = ObjectId.NewObjectId(),
FirstName = $"First_{i}",
LastName = $"Last_{i}",
Age = 20 + (i % 50),
Age = 20 + i % 50,
Bio = null,
CreatedAt = DateTime.UtcNow,
Balance = 1000.50m * (i + 1),
@@ -92,8 +89,7 @@ public class ReadBenchmarks
};
// Add 10 work history items
for (int j = 0; j < 10; j++)
{
for (var j = 0; j < 10; j++)
p.EmploymentHistory.Add(new WorkHistory
{
CompanyName = $"TechCorp_{i}_{j}",
@@ -101,13 +97,12 @@ public class ReadBenchmarks
DurationYears = j,
Tags = new List<string> { "C#", "BSON", "Performance", "Database", "Complex" }
});
}
return p;
}
/// <summary>
/// Tests document db find by id.
/// Tests document db find by id.
/// </summary>
[Benchmark(Baseline = true, Description = "CBDD FindById")]
[BenchmarkCategory("Read_Single")]
@@ -115,4 +110,4 @@ public class ReadBenchmarks
{
return _collection.FindById(_targetId);
}
}
}