public abstract List<PerformanceRecord> WriteParallelSequential(IEnumerable<TestData> data, PerfTracker perfTracker, int numberOfThreads, out long elapsedMilliseconds);
public abstract PerformanceRecord ReadRandom(IEnumerable<uint> randomIds, PerfTracker perfTracker);
public abstract PerformanceRecord ReadSequential(PerfTracker perfTracker);
public abstract PerformanceRecord ReadParallelRandom(IEnumerable<uint> randomIds, PerfTracker perfTracker, int numberOfThreads);
public abstract PerformanceRecord ReadParallelSequential(PerfTracker perfTracker, int numberOfThreads);
private static void OutputResults(string name, long itemsCount, double duration, long bytes, PerfTracker perfTracker) { foreach (var w in new[] { Console.Out, writer }) { w.WriteLine("{0}:\t{1,10:#,#;;0} items & {4,10:#,#} mb, {2,10:#,#} ops/s {3,10:#,#} mb/sec.", name, itemsCount, itemsCount / (duration / 1000), Math.Round(((double)bytes / (duration / 1000)) / 1024 / 1024, 2), Math.Round((double)bytes / 1024 / 1024, 2)); } writer.WriteLine(string.Join(", ", from f in perfTracker.Checkout() select f.ToString("##,###.00"))); }
static void Main() { var random = new Random(); var buffer = new byte[87 * 1024]; random.NextBytes(buffer); var path = @"c:\work\temp\"; writer = new StreamWriter("output.txt", false) { AutoFlush = true }; var sequentialIds = InitSequentialNumbers(Constants.WriteTransactions * Constants.ItemsPerTransaction, minValueSize: 128, maxValueSize: 128); var randomIds = InitRandomNumbers(Constants.WriteTransactions * Constants.ItemsPerTransaction, minValueSize: 128, maxValueSize: 128); var sequentialIdsLarge = InitSequentialNumbers(Constants.WriteTransactions * Constants.ItemsPerTransaction, minValueSize: 512, maxValueSize: 87 * 1024); var randomIdsLarge = InitRandomNumbers(Constants.WriteTransactions * Constants.ItemsPerTransaction, minValueSize: 512, maxValueSize: 87 * 1024); var performanceTests = new List<IStoragePerformanceTest>() { //new SqlServerTest(buffer), //new SqlLiteTest(path, buffer), //new SqlCeTest(path, buffer), //new LmdbTest(path, buffer), new EsentTest(path, buffer), //new FdbTest(buffer), new VoronTest(path, buffer) }; var perfTracker = new PerfTracker(); for (var i = 0; i < performanceTests.Count; i++) { var test = performanceTests[i]; Console.WriteLine("Testing: " + test.StorageName); PerformanceRecord performanceRecord; List<PerformanceRecord> performanceRecords; long totalDuration; long bytes; long items; performanceRecords = test.WriteSequential(sequentialIds, perfTracker); items = performanceRecords.Sum(x => x.ProcessedItems); totalDuration = performanceRecords.Sum(x => x.Duration); bytes = performanceRecords.Sum(x => x.Bytes); OutputResults("Write Seq", items, totalDuration, bytes, perfTracker); WritePerfData("WriteSeq", test, performanceRecords); performanceRecords = test.WriteParallelSequential(sequentialIds, perfTracker, 2, out totalDuration); items = performanceRecords.Sum(x => x.ProcessedItems); bytes = performanceRecords.Sum(x => x.Bytes); OutputResults("Write Seq [2]", items, totalDuration, bytes, perfTracker); WritePerfData("WriteSeq_Parallel_2", test, performanceRecords); performanceRecords = test.WriteParallelSequential(sequentialIds, perfTracker, 4, out totalDuration); items = performanceRecords.Sum(x => x.ProcessedItems); bytes = performanceRecords.Sum(x => x.Bytes); OutputResults("Write Seq [4]", items, totalDuration, bytes, perfTracker); WritePerfData("WriteSeq_Parallel_4", test, performanceRecords); performanceRecords = test.WriteParallelSequential(sequentialIds, perfTracker, 8, out totalDuration); items = performanceRecords.Sum(x => x.ProcessedItems); bytes = performanceRecords.Sum(x => x.Bytes); OutputResults("Write Seq [8]", items, totalDuration, bytes, perfTracker); WritePerfData("WriteSeq_Parallel_8", test, performanceRecords); performanceRecords = test.WriteParallelSequential(sequentialIds, perfTracker, 16, out totalDuration); items = performanceRecords.Sum(x => x.ProcessedItems); bytes = performanceRecords.Sum(x => x.Bytes); OutputResults("Write Seq [16]", items, totalDuration, bytes, perfTracker); WritePerfData("WriteSeq_Parallel_16", test, performanceRecords); performanceRecord = test.ReadSequential(perfTracker); items = performanceRecord.ProcessedItems; totalDuration = performanceRecord.Duration; bytes = performanceRecord.Bytes; OutputResults("Read Seq", items, totalDuration, bytes, perfTracker); WritePerfData("ReadSeq", test, new List<PerformanceRecord> { performanceRecord }); performanceRecord = test.ReadParallelSequential(perfTracker, 2); items = performanceRecord.ProcessedItems; totalDuration = performanceRecord.Duration; bytes = performanceRecord.Bytes; OutputResults("Read Seq [2]", items, totalDuration, bytes, perfTracker); WritePerfData("ReadSeq_Parallel_2", test, new List<PerformanceRecord> { performanceRecord }); performanceRecord = test.ReadParallelSequential(perfTracker, 4); items = performanceRecord.ProcessedItems; totalDuration = performanceRecord.Duration; bytes = performanceRecord.Bytes; OutputResults("Read Seq [4]", items, totalDuration, bytes, perfTracker); WritePerfData("ReadSeq_Parallel_4", test, new List<PerformanceRecord> { performanceRecord }); performanceRecord = test.ReadParallelSequential(perfTracker, 8); items = performanceRecord.ProcessedItems; totalDuration = performanceRecord.Duration; bytes = performanceRecord.Bytes; OutputResults("Read Seq [8]", items, totalDuration, bytes, perfTracker); WritePerfData("ReadSeq_Parallel_8", test, new List<PerformanceRecord> { performanceRecord }); performanceRecord = test.ReadParallelSequential(perfTracker, 16); items = performanceRecord.ProcessedItems; totalDuration = performanceRecord.Duration; bytes = performanceRecord.Bytes; OutputResults("Read Seq [16]", items, totalDuration, bytes, perfTracker); WritePerfData("ReadSeq_Parallel_16", test, new List<PerformanceRecord> { performanceRecord }); performanceRecords = test.WriteRandom(randomIds, perfTracker); items = performanceRecords.Sum(x => x.ProcessedItems); totalDuration = performanceRecords.Sum(x => x.Duration); bytes = performanceRecords.Sum(x => x.Bytes); OutputResults("Write Rnd", items, totalDuration, bytes, perfTracker); WritePerfData("WriteRnd", test, performanceRecords); performanceRecords = test.WriteParallelRandom(randomIds, perfTracker, 2, out totalDuration); items = performanceRecords.Sum(x => x.ProcessedItems); bytes = performanceRecords.Sum(x => x.Bytes); OutputResults("Write Rnd [2]", items, totalDuration, bytes, perfTracker); WritePerfData("WriteRnd_Parallel_2", test, performanceRecords); performanceRecords = test.WriteParallelRandom(randomIds, perfTracker, 4, out totalDuration); items = performanceRecords.Sum(x => x.ProcessedItems); bytes = performanceRecords.Sum(x => x.Bytes); OutputResults("Write Rnd [4]", items, totalDuration, bytes, perfTracker); WritePerfData("WriteRnd_Parallel_4", test, performanceRecords); performanceRecords = test.WriteParallelRandom(randomIds, perfTracker, 8, out totalDuration); items = performanceRecords.Sum(x => x.ProcessedItems); bytes = performanceRecords.Sum(x => x.Bytes); OutputResults("Write Rnd [8]", items, totalDuration, bytes, perfTracker); WritePerfData("WriteRnd_Parallel_8", test, performanceRecords); performanceRecords = test.WriteParallelRandom(randomIds, perfTracker, 16, out totalDuration); items = performanceRecords.Sum(x => x.ProcessedItems); bytes = performanceRecords.Sum(x => x.Bytes); OutputResults("Write Rnd [16]", items, totalDuration, bytes, perfTracker); WritePerfData("WriteRnd_Parallel_16", test, performanceRecords); performanceRecord = test.ReadRandom(randomIds.Select(x => x.Id), perfTracker); items = performanceRecord.ProcessedItems; totalDuration = performanceRecord.Duration; bytes = performanceRecord.Bytes; OutputResults("Read Rnd", items, totalDuration, bytes, perfTracker); WritePerfData("ReadRnd", test, new List<PerformanceRecord> { performanceRecord }); performanceRecord = test.ReadParallelRandom(randomIds.Select(x => x.Id), perfTracker, 2); items = performanceRecord.ProcessedItems; totalDuration = performanceRecord.Duration; bytes = performanceRecord.Bytes; OutputResults("Read Rnd [2]", items, totalDuration, bytes, perfTracker); WritePerfData("ReadRnd_Parallel_2", test, new List<PerformanceRecord> { performanceRecord }); performanceRecord = test.ReadParallelRandom(randomIds.Select(x => x.Id), perfTracker, 4); items = performanceRecord.ProcessedItems; totalDuration = performanceRecord.Duration; bytes = performanceRecord.Bytes; OutputResults("Read Rnd [4]", items, totalDuration, bytes, perfTracker); WritePerfData("ReadRnd_Parallel_4", test, new List<PerformanceRecord> { performanceRecord }); performanceRecord = test.ReadParallelRandom(randomIds.Select(x => x.Id), perfTracker, 8); items = performanceRecord.ProcessedItems; totalDuration = performanceRecord.Duration; bytes = performanceRecord.Bytes; OutputResults("Read Rnd [8]", items, totalDuration, bytes, perfTracker); WritePerfData("ReadRnd_Parallel_8", test, new List<PerformanceRecord> { performanceRecord }); performanceRecord = test.ReadParallelRandom(randomIds.Select(x => x.Id), perfTracker, 16); items = performanceRecord.ProcessedItems; totalDuration = performanceRecord.Duration; bytes = performanceRecord.Bytes; OutputResults("Read Rnd [16]", items, totalDuration, bytes, perfTracker); WritePerfData("ReadRnd_Parallel_16", test, new List<PerformanceRecord> { performanceRecord }); if (test.CanHandleBigData == false) continue; performanceRecords = test.WriteSequential(sequentialIdsLarge, perfTracker); items = performanceRecords.Sum(x => x.ProcessedItems); totalDuration = performanceRecords.Sum(x => x.Duration); bytes = performanceRecords.Sum(x => x.Bytes); OutputResults("Write Lrg Seq", items, totalDuration, bytes, perfTracker); WritePerfData("WriteLrgSeq", test, performanceRecords); performanceRecord = test.ReadSequential(perfTracker); items = performanceRecord.ProcessedItems; totalDuration = performanceRecord.Duration; bytes = performanceRecord.Bytes; OutputResults("Read Lrg Seq", items, totalDuration, bytes, perfTracker); WritePerfData("ReadLrgSeq", test, new List<PerformanceRecord> { performanceRecord }); performanceRecords = test.WriteRandom(randomIdsLarge, perfTracker); items = performanceRecords.Sum(x => x.ProcessedItems); totalDuration = performanceRecords.Sum(x => x.Duration); bytes = performanceRecords.Sum(x => x.Bytes); OutputResults("Write Lrg Rnd", items, totalDuration, bytes, perfTracker); WritePerfData("WriteLrgRnd", test, performanceRecords); performanceRecord = test.ReadRandom(randomIdsLarge.Select(x => x.Id), perfTracker); items = performanceRecord.ProcessedItems; totalDuration = performanceRecord.Duration; bytes = performanceRecord.Bytes; OutputResults("Read Lrg Rnd", items, totalDuration, bytes, perfTracker); WritePerfData("ReadLrgSeq", test, new List<PerformanceRecord> { performanceRecord }); } }
public abstract PerformanceRecord ReadRandom(IEnumerable <uint> randomIds, PerfTracker perfTracker);
public abstract PerformanceRecord ReadParallelRandom(IEnumerable <uint> randomIds, PerfTracker perfTracker, int numberOfThreads);
public abstract PerformanceRecord ReadSequential(PerfTracker perfTracker);
public abstract PerformanceRecord ReadParallelSequential(PerfTracker perfTracker, int numberOfThreads);
public abstract List <PerformanceRecord> WriteParallelRandom(IEnumerable <TestData> data, PerfTracker perfTracker, int numberOfThreads, out long elapsedMilliseconds);
public abstract List <PerformanceRecord> WriteRandom(IEnumerable <TestData> data, PerfTracker perfTracker);
public abstract List <PerformanceRecord> WriteSequential(IEnumerable <TestData> data, PerfTracker perfTracker);
public abstract List<PerformanceRecord> WriteRandom(IEnumerable<TestData> data, PerfTracker perfTracker);
private static void OutputResults(string name, long itemsCount, double duration, long bytes, PerfTracker perfTracker) { foreach (var w in new[]{Console.Out, writer}) { w.WriteLine("{0}:\t{1,10:#,#;;0} items & {4,10:#,#} mb, {2,10:#,#} ops/s {3,10:#,#} mb/sec.", name, itemsCount, itemsCount / (duration / 1000), Math.Round(((double)bytes / (duration / 1000)) / 1024 / 1024, 2), Math.Round((double)bytes / 1024 / 1024, 2)); } writer.WriteLine(string.Join(", ", from f in perfTracker.Checkout() select f.ToString("##,###.00"))); }
public abstract List<PerformanceRecord> WriteSequential(IEnumerable<TestData> data, PerfTracker perfTracker);
static void Main() { var random = new Random(); var buffer = new byte[87 * 1024]; random.NextBytes(buffer); var path = @"c:\work\temp\"; writer = new StreamWriter("output.txt", false) { AutoFlush = true }; var sequentialIds = InitSequentialNumbers(Constants.WriteTransactions * Constants.ItemsPerTransaction, minValueSize: 128, maxValueSize: 128); var randomIds = InitRandomNumbers(Constants.WriteTransactions * Constants.ItemsPerTransaction, minValueSize: 128, maxValueSize: 128); var sequentialIdsLarge = InitSequentialNumbers(Constants.WriteTransactions * Constants.ItemsPerTransaction, minValueSize: 512, maxValueSize: 87 * 1024); var randomIdsLarge = InitRandomNumbers(Constants.WriteTransactions * Constants.ItemsPerTransaction, minValueSize: 512, maxValueSize: 87 * 1024); var performanceTests = new List <IStoragePerformanceTest>() { //new SqlServerTest(buffer), //new SqlLiteTest(path, buffer), //new SqlCeTest(path, buffer), //new LmdbTest(path, buffer), new EsentTest(path, buffer), //new FdbTest(buffer), new VoronTest(path, buffer) }; var perfTracker = new PerfTracker(); for (var i = 0; i < performanceTests.Count; i++) { var test = performanceTests[i]; Console.WriteLine("Testing: " + test.StorageName); PerformanceRecord performanceRecord; List <PerformanceRecord> performanceRecords; long totalDuration; long bytes; long items; performanceRecords = test.WriteSequential(sequentialIds, perfTracker); items = performanceRecords.Sum(x => x.ProcessedItems); totalDuration = performanceRecords.Sum(x => x.Duration); bytes = performanceRecords.Sum(x => x.Bytes); OutputResults("Write Seq", items, totalDuration, bytes, perfTracker); WritePerfData("WriteSeq", test, performanceRecords); performanceRecords = test.WriteParallelSequential(sequentialIds, perfTracker, 2, out totalDuration); items = performanceRecords.Sum(x => x.ProcessedItems); bytes = performanceRecords.Sum(x => x.Bytes); OutputResults("Write Seq [2]", items, totalDuration, bytes, perfTracker); WritePerfData("WriteSeq_Parallel_2", test, performanceRecords); performanceRecords = test.WriteParallelSequential(sequentialIds, perfTracker, 4, out totalDuration); items = performanceRecords.Sum(x => x.ProcessedItems); bytes = performanceRecords.Sum(x => x.Bytes); OutputResults("Write Seq [4]", items, totalDuration, bytes, perfTracker); WritePerfData("WriteSeq_Parallel_4", test, performanceRecords); performanceRecords = test.WriteParallelSequential(sequentialIds, perfTracker, 8, out totalDuration); items = performanceRecords.Sum(x => x.ProcessedItems); bytes = performanceRecords.Sum(x => x.Bytes); OutputResults("Write Seq [8]", items, totalDuration, bytes, perfTracker); WritePerfData("WriteSeq_Parallel_8", test, performanceRecords); performanceRecords = test.WriteParallelSequential(sequentialIds, perfTracker, 16, out totalDuration); items = performanceRecords.Sum(x => x.ProcessedItems); bytes = performanceRecords.Sum(x => x.Bytes); OutputResults("Write Seq [16]", items, totalDuration, bytes, perfTracker); WritePerfData("WriteSeq_Parallel_16", test, performanceRecords); performanceRecord = test.ReadSequential(perfTracker); items = performanceRecord.ProcessedItems; totalDuration = performanceRecord.Duration; bytes = performanceRecord.Bytes; OutputResults("Read Seq", items, totalDuration, bytes, perfTracker); WritePerfData("ReadSeq", test, new List <PerformanceRecord> { performanceRecord }); performanceRecord = test.ReadParallelSequential(perfTracker, 2); items = performanceRecord.ProcessedItems; totalDuration = performanceRecord.Duration; bytes = performanceRecord.Bytes; OutputResults("Read Seq [2]", items, totalDuration, bytes, perfTracker); WritePerfData("ReadSeq_Parallel_2", test, new List <PerformanceRecord> { performanceRecord }); performanceRecord = test.ReadParallelSequential(perfTracker, 4); items = performanceRecord.ProcessedItems; totalDuration = performanceRecord.Duration; bytes = performanceRecord.Bytes; OutputResults("Read Seq [4]", items, totalDuration, bytes, perfTracker); WritePerfData("ReadSeq_Parallel_4", test, new List <PerformanceRecord> { performanceRecord }); performanceRecord = test.ReadParallelSequential(perfTracker, 8); items = performanceRecord.ProcessedItems; totalDuration = performanceRecord.Duration; bytes = performanceRecord.Bytes; OutputResults("Read Seq [8]", items, totalDuration, bytes, perfTracker); WritePerfData("ReadSeq_Parallel_8", test, new List <PerformanceRecord> { performanceRecord }); performanceRecord = test.ReadParallelSequential(perfTracker, 16); items = performanceRecord.ProcessedItems; totalDuration = performanceRecord.Duration; bytes = performanceRecord.Bytes; OutputResults("Read Seq [16]", items, totalDuration, bytes, perfTracker); WritePerfData("ReadSeq_Parallel_16", test, new List <PerformanceRecord> { performanceRecord }); performanceRecords = test.WriteRandom(randomIds, perfTracker); items = performanceRecords.Sum(x => x.ProcessedItems); totalDuration = performanceRecords.Sum(x => x.Duration); bytes = performanceRecords.Sum(x => x.Bytes); OutputResults("Write Rnd", items, totalDuration, bytes, perfTracker); WritePerfData("WriteRnd", test, performanceRecords); performanceRecords = test.WriteParallelRandom(randomIds, perfTracker, 2, out totalDuration); items = performanceRecords.Sum(x => x.ProcessedItems); bytes = performanceRecords.Sum(x => x.Bytes); OutputResults("Write Rnd [2]", items, totalDuration, bytes, perfTracker); WritePerfData("WriteRnd_Parallel_2", test, performanceRecords); performanceRecords = test.WriteParallelRandom(randomIds, perfTracker, 4, out totalDuration); items = performanceRecords.Sum(x => x.ProcessedItems); bytes = performanceRecords.Sum(x => x.Bytes); OutputResults("Write Rnd [4]", items, totalDuration, bytes, perfTracker); WritePerfData("WriteRnd_Parallel_4", test, performanceRecords); performanceRecords = test.WriteParallelRandom(randomIds, perfTracker, 8, out totalDuration); items = performanceRecords.Sum(x => x.ProcessedItems); bytes = performanceRecords.Sum(x => x.Bytes); OutputResults("Write Rnd [8]", items, totalDuration, bytes, perfTracker); WritePerfData("WriteRnd_Parallel_8", test, performanceRecords); performanceRecords = test.WriteParallelRandom(randomIds, perfTracker, 16, out totalDuration); items = performanceRecords.Sum(x => x.ProcessedItems); bytes = performanceRecords.Sum(x => x.Bytes); OutputResults("Write Rnd [16]", items, totalDuration, bytes, perfTracker); WritePerfData("WriteRnd_Parallel_16", test, performanceRecords); performanceRecord = test.ReadRandom(randomIds.Select(x => x.Id), perfTracker); items = performanceRecord.ProcessedItems; totalDuration = performanceRecord.Duration; bytes = performanceRecord.Bytes; OutputResults("Read Rnd", items, totalDuration, bytes, perfTracker); WritePerfData("ReadRnd", test, new List <PerformanceRecord> { performanceRecord }); performanceRecord = test.ReadParallelRandom(randomIds.Select(x => x.Id), perfTracker, 2); items = performanceRecord.ProcessedItems; totalDuration = performanceRecord.Duration; bytes = performanceRecord.Bytes; OutputResults("Read Rnd [2]", items, totalDuration, bytes, perfTracker); WritePerfData("ReadRnd_Parallel_2", test, new List <PerformanceRecord> { performanceRecord }); performanceRecord = test.ReadParallelRandom(randomIds.Select(x => x.Id), perfTracker, 4); items = performanceRecord.ProcessedItems; totalDuration = performanceRecord.Duration; bytes = performanceRecord.Bytes; OutputResults("Read Rnd [4]", items, totalDuration, bytes, perfTracker); WritePerfData("ReadRnd_Parallel_4", test, new List <PerformanceRecord> { performanceRecord }); performanceRecord = test.ReadParallelRandom(randomIds.Select(x => x.Id), perfTracker, 8); items = performanceRecord.ProcessedItems; totalDuration = performanceRecord.Duration; bytes = performanceRecord.Bytes; OutputResults("Read Rnd [8]", items, totalDuration, bytes, perfTracker); WritePerfData("ReadRnd_Parallel_8", test, new List <PerformanceRecord> { performanceRecord }); performanceRecord = test.ReadParallelRandom(randomIds.Select(x => x.Id), perfTracker, 16); items = performanceRecord.ProcessedItems; totalDuration = performanceRecord.Duration; bytes = performanceRecord.Bytes; OutputResults("Read Rnd [16]", items, totalDuration, bytes, perfTracker); WritePerfData("ReadRnd_Parallel_16", test, new List <PerformanceRecord> { performanceRecord }); if (test.CanHandleBigData == false) { continue; } performanceRecords = test.WriteSequential(sequentialIdsLarge, perfTracker); items = performanceRecords.Sum(x => x.ProcessedItems); totalDuration = performanceRecords.Sum(x => x.Duration); bytes = performanceRecords.Sum(x => x.Bytes); OutputResults("Write Lrg Seq", items, totalDuration, bytes, perfTracker); WritePerfData("WriteLrgSeq", test, performanceRecords); performanceRecord = test.ReadSequential(perfTracker); items = performanceRecord.ProcessedItems; totalDuration = performanceRecord.Duration; bytes = performanceRecord.Bytes; OutputResults("Read Lrg Seq", items, totalDuration, bytes, perfTracker); WritePerfData("ReadLrgSeq", test, new List <PerformanceRecord> { performanceRecord }); performanceRecords = test.WriteRandom(randomIdsLarge, perfTracker); items = performanceRecords.Sum(x => x.ProcessedItems); totalDuration = performanceRecords.Sum(x => x.Duration); bytes = performanceRecords.Sum(x => x.Bytes); OutputResults("Write Lrg Rnd", items, totalDuration, bytes, perfTracker); WritePerfData("WriteLrgRnd", test, performanceRecords); performanceRecord = test.ReadRandom(randomIdsLarge.Select(x => x.Id), perfTracker); items = performanceRecord.ProcessedItems; totalDuration = performanceRecord.Duration; bytes = performanceRecord.Bytes; OutputResults("Read Lrg Rnd", items, totalDuration, bytes, perfTracker); WritePerfData("ReadLrgSeq", test, new List <PerformanceRecord> { performanceRecord }); } }