Reformat / cleanup
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
using System.Text;
|
||||
using BenchmarkDotNet.Attributes;
|
||||
using BenchmarkDotNet.Configs;
|
||||
using BenchmarkDotNet.Jobs;
|
||||
using ZB.MOM.WW.CBDD.Bson;
|
||||
using ZB.MOM.WW.CBDD.Core.Collections;
|
||||
using ZB.MOM.WW.CBDD.Core.Storage;
|
||||
@@ -15,21 +15,22 @@ namespace ZB.MOM.WW.CBDD.Tests.Benchmark;
|
||||
[JsonExporterAttribute.Full]
|
||||
public class CompactionBenchmarks
|
||||
{
|
||||
private readonly List<ObjectId> _insertedIds = [];
|
||||
private DocumentCollection<Person> _collection = null!;
|
||||
|
||||
private string _dbPath = string.Empty;
|
||||
private StorageEngine _storage = null!;
|
||||
private BenchmarkTransactionHolder _transactionHolder = null!;
|
||||
private string _walPath = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the number of documents used per benchmark iteration.
|
||||
/// Gets or sets the number of documents used per benchmark iteration.
|
||||
/// </summary>
|
||||
[Params(2_000)]
|
||||
public int DocumentCount { get; set; }
|
||||
|
||||
private string _dbPath = string.Empty;
|
||||
private string _walPath = string.Empty;
|
||||
private StorageEngine _storage = null!;
|
||||
private BenchmarkTransactionHolder _transactionHolder = null!;
|
||||
private DocumentCollection<Person> _collection = null!;
|
||||
private List<ObjectId> _insertedIds = [];
|
||||
|
||||
/// <summary>
|
||||
/// Prepares benchmark state and seed data for each iteration.
|
||||
/// Prepares benchmark state and seed data for each iteration.
|
||||
/// </summary>
|
||||
[IterationSetup]
|
||||
public void Setup()
|
||||
@@ -53,17 +54,14 @@ public class CompactionBenchmarks
|
||||
_transactionHolder.CommitAndReset();
|
||||
_storage.Checkpoint();
|
||||
|
||||
for (var i = _insertedIds.Count - 1; i >= _insertedIds.Count / 3; i--)
|
||||
{
|
||||
_collection.Delete(_insertedIds[i]);
|
||||
}
|
||||
for (int i = _insertedIds.Count - 1; i >= _insertedIds.Count / 3; i--) _collection.Delete(_insertedIds[i]);
|
||||
|
||||
_transactionHolder.CommitAndReset();
|
||||
_storage.Checkpoint();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cleans up benchmark resources and temporary files after each iteration.
|
||||
/// Cleans up benchmark resources and temporary files after each iteration.
|
||||
/// </summary>
|
||||
[IterationCleanup]
|
||||
public void Cleanup()
|
||||
@@ -76,7 +74,7 @@ public class CompactionBenchmarks
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Benchmarks reclaimed file bytes reported by offline compaction.
|
||||
/// Benchmarks reclaimed file bytes reported by offline compaction.
|
||||
/// </summary>
|
||||
/// <returns>The reclaimed file byte count.</returns>
|
||||
[Benchmark(Baseline = true)]
|
||||
@@ -95,7 +93,7 @@ public class CompactionBenchmarks
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Benchmarks tail bytes truncated by offline compaction.
|
||||
/// Benchmarks tail bytes truncated by offline compaction.
|
||||
/// </summary>
|
||||
/// <returns>The truncated tail byte count.</returns>
|
||||
[Benchmark]
|
||||
@@ -135,7 +133,7 @@ public class CompactionBenchmarks
|
||||
|
||||
private static string BuildPayload(int seed)
|
||||
{
|
||||
var builder = new System.Text.StringBuilder(2500);
|
||||
var builder = new StringBuilder(2500);
|
||||
for (var i = 0; i < 80; i++)
|
||||
{
|
||||
builder.Append("compact-");
|
||||
@@ -147,4 +145,4 @@ public class CompactionBenchmarks
|
||||
|
||||
return builder.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user