@@ -19,104 +19,104 @@ namespace Jering.KeyValueStore.Performance
1919 [ MemoryDiagnoser ]
2020 public class LowMemoryUsageBenchmarks
2121 {
22- #pragma warning disable CS8618
23- private IMixedStorageKVStore < int , DummyClass > _mixedStorageKVStore ;
24- private MixedStorageKVStoreOptions _mixedStorageKVStoreOptions ;
25- #pragma warning restore CS8618
26- private const int NUM_INSERT_OPERATIONS = 350_000 ;
27- private const int NUM_READ_OPERATIONS = 75_000 ;
28- private readonly ConcurrentQueue < ValueTask < ( Status , DummyClass ? ) > > _readTasks = new ( ) ;
29- private readonly DummyClass _dummyClassInstance = new ( )
30- {
31- // Populate with dummy values
32- DummyString = "dummyString" ,
33- DummyStringArray = new [ ] { "dummyString1" , "dummyString2" , "dummyString3" , "dummyString4" , "dummyString5" } ,
34- DummyInt = 10 ,
35- DummyIntArray = new [ ] { 10 , 100 , 1000 , 10000 , 100000 , 1000000 , 10000000 }
36- } ;
22+ // #pragma warning disable CS8618
23+ // private MixedStorageKVStore <int, DummyClass> _mixedStorageKVStore;
24+ // private MixedStorageKVStoreOptions _mixedStorageKVStoreOptions;
25+ // #pragma warning restore CS8618
26+ // private const int NUM_INSERT_OPERATIONS = 350_000;
27+ // private const int NUM_READ_OPERATIONS = 75_000;
28+ // private readonly ConcurrentQueue<ValueTask<(Status, DummyClass?)>> _readTasks = new();
29+ // private readonly DummyClass _dummyClassInstance = new()
30+ // {
31+ // // Populate with dummy values
32+ // DummyString = "dummyString",
33+ // DummyStringArray = new[] { "dummyString1", "dummyString2", "dummyString3", "dummyString4", "dummyString5" },
34+ // DummyInt = 10,
35+ // DummyIntArray = new[] { 10, 100, 1000, 10000, 100000, 1000000, 10000000 }
36+ // };
3737
38- // Concurrent inserts without compression
39- [ GlobalSetup ( Target = nameof ( Inserts_WithoutCompression ) ) ]
40- public void Inserts_WithoutCompression_GlobalSetup ( )
41- {
42- _mixedStorageKVStoreOptions = new ( )
43- {
44- PageSizeBits = 12 , // 4 KB
45- MemorySizeBits = 13 , // 2 pages
46- TimeBetweenLogCompactionsMS = - 1 , // Disable log compactions
47- MessagePackSerializerOptions = MessagePackSerializerOptions . Standard
48- } ;
49- }
38+ // // Concurrent inserts without compression
39+ // [GlobalSetup(Target = nameof(Inserts_WithoutCompression))]
40+ // public void Inserts_WithoutCompression_GlobalSetup()
41+ // {
42+ // _mixedStorageKVStoreOptions = new()
43+ // {
44+ // PageSizeBits = 12, // 4 KB
45+ // MemorySizeBits = 13, // 2 pages
46+ // TimeBetweenLogCompactionsMS = -1, // Disable log compactions
47+ // MessagePackSerializerOptions = MessagePackSerializerOptions.Standard
48+ // };
49+ // }
5050
51- [ IterationSetup ( Target = nameof ( Inserts_WithoutCompression ) ) ]
52- public void Inserts_WithoutCompression_IterationSetup ( )
53- {
54- _mixedStorageKVStore = new MixedStorageKVStore < int , DummyClass > ( _mixedStorageKVStoreOptions ) ;
55- }
51+ // [IterationSetup(Target = nameof(Inserts_WithoutCompression))]
52+ // public void Inserts_WithoutCompression_IterationSetup()
53+ // {
54+ // _mixedStorageKVStore = new MixedStorageKVStore<int, DummyClass>(_mixedStorageKVStoreOptions);
55+ // }
5656
57- [ Benchmark ]
58- public void Inserts_WithoutCompression ( )
59- {
60- Parallel . For ( 0 , NUM_INSERT_OPERATIONS , key => _mixedStorageKVStore . Upsert ( key , _dummyClassInstance ) ) ;
61- }
57+ // [Benchmark]
58+ // public void Inserts_WithoutCompression()
59+ // {
60+ // Parallel.For(0, NUM_INSERT_OPERATIONS, key => _mixedStorageKVStore.Upsert(key, _dummyClassInstance));
61+ // }
6262
63- [ IterationCleanup ( Target = nameof ( Inserts_WithoutCompression ) ) ]
64- public void Inserts_WithoutCompression_IterationCleanup ( )
65- {
66- _mixedStorageKVStore . Dispose ( ) ;
67- }
63+ // [IterationCleanup(Target = nameof(Inserts_WithoutCompression))]
64+ // public void Inserts_WithoutCompression_IterationCleanup()
65+ // {
66+ // _mixedStorageKVStore.Dispose();
67+ // }
6868
69- // Concurrent reads without compression
70- [ GlobalSetup ( Target = nameof ( Reads_WithoutCompression ) ) ]
71- public void Reads_WithoutCompression_GlobalSetup ( )
72- {
73- _mixedStorageKVStoreOptions = new ( )
74- {
75- PageSizeBits = 12 , // 4 KB
76- MemorySizeBits = 13 , // 2 pages
77- TimeBetweenLogCompactionsMS = - 1 , // Disable log compactions
78- MessagePackSerializerOptions = MessagePackSerializerOptions . Standard
79- } ;
80- _mixedStorageKVStore = new MixedStorageKVStore < int , DummyClass > ( _mixedStorageKVStoreOptions ) ;
81- Parallel . For ( 0 , NUM_READ_OPERATIONS , key => _mixedStorageKVStore . Upsert ( key , _dummyClassInstance ) ) ;
82- }
69+ // // Concurrent reads without compression
70+ // [GlobalSetup(Target = nameof(Reads_WithoutCompression))]
71+ // public void Reads_WithoutCompression_GlobalSetup()
72+ // {
73+ // _mixedStorageKVStoreOptions = new()
74+ // {
75+ // PageSizeBits = 12, // 4 KB
76+ // MemorySizeBits = 13, // 2 pages
77+ // TimeBetweenLogCompactionsMS = -1, // Disable log compactions
78+ // MessagePackSerializerOptions = MessagePackSerializerOptions.Standard
79+ // };
80+ // _mixedStorageKVStore = new MixedStorageKVStore<int, DummyClass>(_mixedStorageKVStoreOptions);
81+ // Parallel.For(0, NUM_READ_OPERATIONS, key => _mixedStorageKVStore.Upsert(key, _dummyClassInstance));
82+ // }
8383
84- [ IterationSetup ( Target = nameof ( Reads_WithoutCompression ) ) ]
85- public void Reads_WithoutCompression_IterationSetup ( )
86- {
87- _readTasks . Clear ( ) ;
88- }
84+ // [IterationSetup(Target = nameof(Reads_WithoutCompression))]
85+ // public void Reads_WithoutCompression_IterationSetup()
86+ // {
87+ // _readTasks.Clear();
88+ // }
8989
90- [ Benchmark ]
91- public async Task Reads_WithoutCompression ( )
92- {
93- Parallel . For ( 0 , NUM_READ_OPERATIONS , key => _readTasks . Enqueue ( _mixedStorageKVStore . ReadAsync ( key ) ) ) ;
94- foreach ( ValueTask < ( Status , DummyClass ? ) > task in _readTasks )
95- {
96- await task . ConfigureAwait ( false ) ;
97- }
98- }
90+ // [Benchmark]
91+ // public async Task Reads_WithoutCompression()
92+ // {
93+ // Parallel.For(0, NUM_READ_OPERATIONS, key => _readTasks.Enqueue(_mixedStorageKVStore.ReadAsync(key)));
94+ // foreach(ValueTask<(Status, DummyClass?)> task in _readTasks)
95+ // {
96+ // await task.ConfigureAwait(false);
97+ // }
98+ // }
9999
100- [ GlobalCleanup ( Target = nameof ( Reads_WithoutCompression ) ) ]
101- public void Reads_WithoutCompression_GlobalCleanup ( )
102- {
103- _mixedStorageKVStore . Dispose ( ) ;
104- }
100+ // [GlobalCleanup(Target = nameof(Reads_WithoutCompression))]
101+ // public void Reads_WithoutCompression_GlobalCleanup()
102+ // {
103+ // _mixedStorageKVStore.Dispose();
104+ // }
105105
106- [ MessagePackObject ]
107- public class DummyClass
108- {
109- [ Key ( 0 ) ]
110- public string ? DummyString { get ; set ; }
106+ // [MessagePackObject]
107+ // public class DummyClass
108+ // {
109+ // [Key(0)]
110+ // public string? DummyString { get; set; }
111111
112- [ Key ( 1 ) ]
113- public string [ ] ? DummyStringArray { get ; set ; }
112+ // [Key(1)]
113+ // public string[]? DummyStringArray { get; set; }
114114
115- [ Key ( 2 ) ]
116- public int DummyInt { get ; set ; }
115+ // [Key(2)]
116+ // public int DummyInt { get; set; }
117117
118- [ Key ( 3 ) ]
119- public int [ ] ? DummyIntArray { get ; set ; }
120- }
118+ // [Key(3)]
119+ // public int[]? DummyIntArray { get; set; }
120+ // }
121121 }
122122}
0 commit comments