private void Run(Action <BenchmarkIteration, ObjectDB <IFlatbufferObject>, IFlatbufferObject> action, int dataIndex, int dataSize) { var data = InputData[dataIndex]; var factories = new List <Func <ByteBuffer, IFlatbufferObject> > { (bb) => Data_8b.GetRootAsData_8b(bb), (bb) => Data_128b.GetRootAsData_128b(bb), (bb) => Data_1KB.GetRootAsData_1KB(bb), (bb) => Data_1MB.GetRootAsData_1MB(bb), }; var nRecords = dataSize; var buffer = 100_000; using (var db = new ObjectDB <IFlatbufferObject>(FileStorageEngineFactory.Create("benchmark", SIZE_15GB, nRecords + buffer), new FlatBufferSerializer(factories))) { // set up data for (int i = 0; i < nRecords; i++) { db.Insert(data); if (i % 10000 == 0 && i > 0) { Console.WriteLine(i); } } // run benchmark foreach (BenchmarkIteration iter in Benchmark.Iterations) { action(iter, db, data); } } }
static Benchmarks() { { var builder = new FlatBufferBuilder(8); var offset = Data_8b.CreateData_8b(builder); builder.Finish(offset.Value); InputData.Add(Data_8b.GetRootAsData_8b(builder.DataBuffer)); } { var builder = new FlatBufferBuilder(128); List <Offset <Data_8b> > inner8b = new List <Offset <Data_8b> >(); for (var i = 0; i < 16; i++) { inner8b.Add(Data_8b.CreateData_8b(builder)); } var innerOffset = Data_128b.CreateInnerVector(builder, inner8b.ToArray()); var offset = Data_128b.CreateData_128b(builder, innerOffset); builder.Finish(offset.Value); InputData.Add(Data_128b.GetRootAsData_128b(builder.DataBuffer)); } { var builder = new FlatBufferBuilder(128); List <Offset <Data_128b> > inner128b = new List <Offset <Data_128b> >(); for (var i = 0; i < 8; i++) { List <Offset <Data_8b> > inner8b = new List <Offset <Data_8b> >(); for (var j = 0; j < 16; j++) { inner8b.Add(Data_8b.CreateData_8b(builder)); } var inner8bOffset = Data_128b.CreateInnerVector(builder, inner8b.ToArray()); inner128b.Add(Data_128b.CreateData_128b(builder, inner8bOffset)); } var innerOffset = Data_1KB.CreateInnerVector(builder, inner128b.ToArray()); var offset = Data_1KB.CreateData_1KB(builder, innerOffset); builder.Finish(offset.Value); InputData.Add(Data_1KB.GetRootAsData_1KB(builder.DataBuffer)); } { var builder = new FlatBufferBuilder(128); List <Offset <Data_1KB> > inner1kb = new List <Offset <Data_1KB> >(); for (var i = 0; i < 1024; i++) { List <Offset <Data_128b> > inner128b = new List <Offset <Data_128b> >(); for (var j = 0; j < 8; j++) { List <Offset <Data_8b> > inner8b = new List <Offset <Data_8b> >(); for (var k = 0; k < 16; k++) { inner8b.Add(Data_8b.CreateData_8b(builder)); } var inner8bOffset = Data_128b.CreateInnerVector(builder, inner8b.ToArray()); inner128b.Add(Data_128b.CreateData_128b(builder, inner8bOffset)); } var inner128bOffset = Data_1KB.CreateInnerVector(builder, inner128b.ToArray()); inner1kb.Add(Data_1KB.CreateData_1KB(builder, inner128bOffset)); } var innerOffset = Data_1MB.CreateInnerVector(builder, inner1kb.ToArray()); var offset = Data_1MB.CreateData_1MB(builder, innerOffset); builder.Finish(offset.Value); InputData.Add(Data_1MB.GetRootAsData_1MB(builder.DataBuffer)); } }