From 6f9c2fed61f82cf6d7883c7d4db69b88dc7368e4 Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Wed, 3 Feb 2021 18:55:14 +1100 Subject: [PATCH] Add batch writes cases to sqlite storage benchmarks --- storage/sqlite/sqlite-storage_test.go | 38 +++++++++++++++------------ 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/storage/sqlite/sqlite-storage_test.go b/storage/sqlite/sqlite-storage_test.go index 65b63205..3f599d51 100644 --- a/storage/sqlite/sqlite-storage_test.go +++ b/storage/sqlite/sqlite-storage_test.go @@ -72,23 +72,27 @@ func BenchmarkMarkComplete(b *testing.B) { c := qt.New(b) for _, memory := range []bool{false, true} { b.Run(fmt.Sprintf("Memory=%v", memory), func(b *testing.B) { - dbPath := filepath.Join(b.TempDir(), "storage.db") - //b.Logf("storage db path: %q", dbPath) - ci, err := NewPiecesStorage(NewPiecesStorageOpts{ - NewPoolOpts: NewPoolOpts{ - Path: dbPath, - Capacity: 4*pieceSize - 1, - NoConcurrentBlobReads: false, - PageSize: 1 << 14, - Memory: memory, - }, - ProvOpts: func(opts *ProviderOpts) { - opts.BatchWrites = true - }, - }) - c.Assert(err, qt.IsNil) - defer ci.Close() - test_storage.BenchmarkPieceMarkComplete(b, ci, pieceSize, 16, capacity) + for _, batchWrites := range []bool{false, true} { + b.Run(fmt.Sprintf("BatchWrites=%v", batchWrites), func(b *testing.B) { + dbPath := filepath.Join(b.TempDir(), "storage.db") + //b.Logf("storage db path: %q", dbPath) + ci, err := NewPiecesStorage(NewPiecesStorageOpts{ + NewPoolOpts: NewPoolOpts{ + Path: dbPath, + Capacity: 4*pieceSize - 1, + NoConcurrentBlobReads: false, + PageSize: 1 << 14, + Memory: memory, + }, + ProvOpts: func(opts *ProviderOpts) { + opts.BatchWrites = batchWrites + }, + }) + c.Assert(err, qt.IsNil) + defer ci.Close() + test_storage.BenchmarkPieceMarkComplete(b, ci, pieceSize, 16, capacity) + }) + } }) } } -- 2.48.1