Created
June 13, 2011 21:39
-
-
Save Bobris/1023790 to your computer and use it in GitHub Desktop.
Benchmark for BTDB
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
void DoWork5(bool alsoDoReads) | |
{ | |
_sw.Restart(); | |
long pureDataLength = 0; | |
using (var stream = new PositionLessStreamProxy("data.btdb")) | |
using (IKeyValueDB db = new KeyValueDB()) | |
{ | |
db.DurableTransactions = true; | |
db.CacheSizeInMB = 40; | |
db.Open(stream, false); | |
for (int i = 0; i < 200; i++) | |
{ | |
long pureDataLengthPrevTr = pureDataLength; | |
using (var tr = db.StartTransaction()) | |
{ | |
for (int j = 0; j < 200; j++) | |
{ | |
tr.CreateOrUpdateKeyValue(new[] { (byte)j, (byte)i }, new byte[1 + i * j]); | |
pureDataLength += 2 + 1 + i * j; | |
} | |
if (alsoDoReads) using (var trCheck = db.StartTransaction()) | |
{ | |
long pureDataLengthCheck = 0; | |
if (trCheck.FindFirstKey()) | |
{ | |
do | |
{ | |
pureDataLengthCheck += trCheck.ReadKey().Length + trCheck.ReadValue().Length; | |
} while (trCheck.FindNextKey()); | |
} | |
if (pureDataLengthCheck != pureDataLengthPrevTr) | |
{ | |
throw new Exception("Transactions are not in serializable mode"); | |
} | |
} | |
tr.Commit(); | |
} | |
} | |
using (var trStat = db.StartTransaction()) | |
{ | |
Console.WriteLine(trStat.CalculateStats().ToString()); | |
} | |
} | |
_sw.Stop(); | |
Console.WriteLine("Pure data length: {0}", pureDataLength); | |
Console.WriteLine("Time: {0,15}ms", _sw.Elapsed.TotalMilliseconds); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment