-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
net7.0 & C# style improvements (#158)
net7.0 LibraryImport, C# 11, and nint changes Re-enable test with path fix Style changes for C# 11 and analysis Updating dependencies
- Loading branch information
1 parent
27ede9a
commit 74df69f
Showing
46 changed files
with
3,532 additions
and
3,469 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,92 +1,85 @@ | ||
using System; | ||
using System.Dynamic; | ||
using System.IO; | ||
|
||
using BenchmarkDotNet; | ||
using BenchmarkDotNet.Attributes; | ||
|
||
using LightningDB; | ||
|
||
using Microsoft.CodeAnalysis.CSharp.Syntax; | ||
namespace LightningDB.Benchmarks; | ||
|
||
namespace LightningDB.Benchmarks | ||
public abstract class BenchmarksBase | ||
{ | ||
public abstract class BenchmarksBase | ||
{ | ||
public LightningEnvironment Env { get; set; } | ||
public LightningDatabase DB { get; set; } | ||
public LightningEnvironment Env { get; set; } | ||
public LightningDatabase DB { get; set; } | ||
|
||
[GlobalSetup] | ||
public void GlobalSetup() | ||
{ | ||
Console.WriteLine("Global Setup Begin"); | ||
[GlobalSetup] | ||
public void GlobalSetup() | ||
{ | ||
Console.WriteLine("Global Setup Begin"); | ||
|
||
const string Path = "TestDirectory"; | ||
const string Path = "TestDirectory"; | ||
|
||
if (Directory.Exists(Path)) | ||
Directory.Delete(Path, true); | ||
if (Directory.Exists(Path)) | ||
Directory.Delete(Path, true); | ||
|
||
Env = new LightningEnvironment(Path) { | ||
MaxDatabases = 1 | ||
}; | ||
Env = new LightningEnvironment(Path) { | ||
MaxDatabases = 1 | ||
}; | ||
|
||
Env.Open(); | ||
Env.Open(); | ||
|
||
using (var tx = Env.BeginTransaction()) { | ||
DB = tx.OpenDatabase(); | ||
tx.Commit(); | ||
} | ||
|
||
RunSetup(); | ||
|
||
using (var tx = Env.BeginTransaction()) { | ||
DB = tx.OpenDatabase(); | ||
tx.Commit(); | ||
} | ||
Console.WriteLine("Global Setup End"); | ||
} | ||
|
||
RunSetup(); | ||
public abstract void RunSetup(); | ||
|
||
Console.WriteLine("Global Setup End"); | ||
} | ||
[GlobalCleanup] | ||
public void GlobalCleanup() | ||
{ | ||
Console.WriteLine("Global Cleanup Begin"); | ||
|
||
public abstract void RunSetup(); | ||
|
||
[GlobalCleanup] | ||
public void GlobalCleanup() | ||
{ | ||
Console.WriteLine("Global Cleanup Begin"); | ||
|
||
try { | ||
DB.Dispose(); | ||
Env.Dispose(); | ||
} | ||
catch(Exception ex) { | ||
Console.WriteLine(ex.ToString()); | ||
} | ||
Console.WriteLine("Global Cleanup End"); | ||
try { | ||
DB.Dispose(); | ||
Env.Dispose(); | ||
} | ||
catch(Exception ex) { | ||
Console.WriteLine(ex.ToString()); | ||
} | ||
Console.WriteLine("Global Cleanup End"); | ||
} | ||
} | ||
|
||
public abstract class RWBenchmarksBase : BenchmarksBase | ||
{ | ||
//***** Argument Matrix Start *****// | ||
[Params(1, 100, 1000)] | ||
public int OpsPerTransaction { get; set; } | ||
public abstract class RWBenchmarksBase : BenchmarksBase | ||
{ | ||
//***** Argument Matrix Start *****// | ||
[Params(1, 100, 1000)] | ||
public int OpsPerTransaction { get; set; } | ||
|
||
[Params(8, 64, 256)] | ||
public int ValueSize { get; set; } | ||
[Params(8, 64, 256)] | ||
public int ValueSize { get; set; } | ||
|
||
[Params(KeyOrdering.Sequential)] | ||
public KeyOrdering KeyOrder { get; set; } | ||
[Params(KeyOrdering.Sequential)] | ||
public KeyOrdering KeyOrder { get; set; } | ||
|
||
//***** Argument Matrix End *****// | ||
//***** Argument Matrix End *****// | ||
|
||
|
||
|
||
//***** Test Values Begin *****// | ||
//***** Test Values Begin *****// | ||
|
||
protected byte[] ValueBuffer { get; private set; } | ||
protected KeyBatch KeyBuffers { get; private set; } | ||
protected byte[] ValueBuffer { get; private set; } | ||
protected KeyBatch KeyBuffers { get; private set; } | ||
|
||
//***** Test Values End *****// | ||
//***** Test Values End *****// | ||
|
||
public override void RunSetup() | ||
{ | ||
ValueBuffer = new byte[ValueSize]; | ||
KeyBuffers = KeyBatch.Generate(OpsPerTransaction, KeyOrder); | ||
} | ||
public override void RunSetup() | ||
{ | ||
ValueBuffer = new byte[ValueSize]; | ||
KeyBuffers = KeyBatch.Generate(OpsPerTransaction, KeyOrder); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,12 @@ | ||
using System; | ||
using BenchmarkDotNet.Running; | ||
|
||
namespace LightningDB.Benchmarks { | ||
public static class Entry | ||
namespace LightningDB.Benchmarks; | ||
|
||
public static class Entry | ||
{ | ||
public static void Main(string[] args) | ||
{ | ||
public static void Main(string[] args) | ||
{ | ||
//BenchmarkRunner.Run<WriteBenchmarks>(); | ||
BenchmarkRunner.Run<ReadBenchmarks>(); | ||
} | ||
//BenchmarkRunner.Run<WriteBenchmarks>(); | ||
BenchmarkRunner.Run<ReadBenchmarks>(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,30 @@ | ||
| ||
using BenchmarkDotNet.Attributes; | ||
|
||
namespace LightningDB.Benchmarks | ||
namespace LightningDB.Benchmarks; | ||
|
||
[MemoryDiagnoser] | ||
public class ReadBenchmarks : RWBenchmarksBase | ||
{ | ||
[MemoryDiagnoser] | ||
public class ReadBenchmarks : RWBenchmarksBase | ||
public override void RunSetup() | ||
{ | ||
public override void RunSetup() | ||
{ | ||
base.RunSetup(); | ||
base.RunSetup(); | ||
|
||
//setup data to read | ||
using var tx = Env.BeginTransaction(); | ||
for (int i = 0; i < KeyBuffers.Count; i++) | ||
tx.Put(DB, KeyBuffers[i], ValueBuffer); | ||
//setup data to read | ||
using var tx = Env.BeginTransaction(); | ||
for (var i = 0; i < KeyBuffers.Count; i++) | ||
tx.Put(DB, KeyBuffers[i], ValueBuffer); | ||
|
||
tx.Commit(); | ||
} | ||
tx.Commit(); | ||
} | ||
|
||
[Benchmark] | ||
public void Read() | ||
{ | ||
using var transaction = Env.BeginTransaction(beginFlags: TransactionBeginFlags.ReadOnly); | ||
[Benchmark] | ||
public void Read() | ||
{ | ||
using var transaction = Env.BeginTransaction(beginFlags: TransactionBeginFlags.ReadOnly); | ||
|
||
for (int i = 0; i < OpsPerTransaction; i++) { | ||
var _ = transaction.Get(DB, KeyBuffers[i]); | ||
} | ||
for (var i = 0; i < OpsPerTransaction; i++) { | ||
var _ = transaction.Get(DB, KeyBuffers[i]); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.