-
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
261 additions
and
54 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
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
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 |
---|---|---|
@@ -0,0 +1,85 @@ | ||
using System.Diagnostics; | ||
using Tenray.ZoneTree; | ||
using Tenray.ZoneTree.Comparers; | ||
using Tenray.ZoneTree.Maintainers; | ||
using Tenray.ZoneTree.Serializers; | ||
using Tenray.ZoneTree.WAL; | ||
|
||
namespace Playground.Benchmark; | ||
|
||
public class ZoneTree3 | ||
{ | ||
public static void TestInsertTransactionIntTree(WriteAheadLogMode mode, int count) | ||
{ | ||
Console.WriteLine("\r\nTestIntTree\r\n"); | ||
Console.WriteLine("Record count = " + count); | ||
Console.WriteLine("WriteAheadLogMode: = " + mode); | ||
|
||
var dataPath = "../../data/TestInsertTransactionIntTree" + mode + count; | ||
if (Directory.Exists(dataPath)) | ||
Directory.Delete(dataPath, true); | ||
|
||
var stopWatch = new Stopwatch(); | ||
stopWatch.Start(); | ||
using var zoneTree = OpenOrCreateZoneTree(mode, dataPath); | ||
using var basicMaintainer = new BasicZoneTreeMaintainer<int, int>(zoneTree); | ||
basicMaintainer.ThresholdForMergeOperationStart = 2_000_000; | ||
|
||
Console.WriteLine("Loaded in: " + stopWatch.ElapsedMilliseconds); | ||
|
||
Parallel.For(0, count, (x) => | ||
{ | ||
zoneTree.UpsertAutoCommit(x, x + x); | ||
}); | ||
|
||
Console.WriteLine("Completed in: " + stopWatch.ElapsedMilliseconds); | ||
basicMaintainer.CompleteRunningTasks().Wait(); | ||
} | ||
|
||
public static void TestIterateIntTree(WriteAheadLogMode mode, int count) | ||
{ | ||
Console.WriteLine("\r\nTestIterationIntTree\r\n"); | ||
Console.WriteLine("Record count = " + count); | ||
Console.WriteLine("WriteAheadLogMode: = " + mode); | ||
|
||
var dataPath = "../../data/TestInsertTransactionIntTree" + mode + count; | ||
var stopWatch = new Stopwatch(); | ||
stopWatch.Start(); | ||
using var zoneTree = OpenOrCreateZoneTree(mode, dataPath); | ||
using var basicMaintainer = new BasicZoneTreeMaintainer<int, int>(zoneTree); | ||
basicMaintainer.ThresholdForMergeOperationStart = 2_000_000; | ||
|
||
Console.WriteLine("Loaded in: " + stopWatch.ElapsedMilliseconds); | ||
|
||
var off = 0; | ||
using var iterator = zoneTree.Maintenance.ZoneTree.CreateIterator(); | ||
while (iterator.Next()) | ||
{ | ||
if (iterator.CurrentKey * 2 != iterator.CurrentValue) | ||
throw new Exception("invalid key or value"); | ||
++off; | ||
} | ||
if (off != count) | ||
throw new Exception($"missing records. {off} != {count}"); | ||
|
||
Console.WriteLine("Completed in: " + stopWatch.ElapsedMilliseconds); | ||
basicMaintainer.CompleteRunningTasks().Wait(); | ||
} | ||
|
||
private static ITransactionalZoneTree<int, int> OpenOrCreateZoneTree(WriteAheadLogMode mode, string dataPath) | ||
{ | ||
return new ZoneTreeFactory<int, int>() | ||
.SetComparer(new Int32ComparerAscending()) | ||
.SetMutableSegmentMaxItemCount(1_000_000) | ||
.SetDataDirectory(dataPath) | ||
.SetWriteAheadLogDirectory(dataPath) | ||
.ConfigureWriteAheadLogProvider(x => | ||
{ | ||
x.WriteAheadLogMode = mode; | ||
x.EnableIncrementalBackup = false; | ||
}) | ||
.SetKeySerializer(new Int32Serializer()) | ||
.SetValueSerializer(new Int32Serializer()) | ||
.OpenOrCreateTransactional(); | ||
} | ||
} |
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,3 +1,3 @@ | ||
using Playground.Benchmark; | ||
|
||
BenchmarkGroups.InsertBenchmark(); | ||
BenchmarkGroups.InsertBenchmark1(); |
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
Oops, something went wrong.