diff --git a/storage/local/fixtures/b0/04b821ca50ba26.db b/storage/local/fixtures/b0/04b821ca50ba26.db new file mode 100644 index 000000000..a9be87364 Binary files /dev/null and b/storage/local/fixtures/b0/04b821ca50ba26.db differ diff --git a/storage/local/fixtures/b0/37c21e884e4fc5.db b/storage/local/fixtures/b0/37c21e884e4fc5.db new file mode 100644 index 000000000..e2427d19b Binary files /dev/null and b/storage/local/fixtures/b0/37c21e884e4fc5.db differ diff --git a/storage/local/fixtures/b0/37de1e884e5469.db b/storage/local/fixtures/b0/37de1e884e5469.db new file mode 100644 index 000000000..3445e0109 Binary files /dev/null and b/storage/local/fixtures/b0/37de1e884e5469.db differ diff --git a/storage/local/persistence_test.go b/storage/local/persistence_test.go index 2edc7d829..d6b75d2ee 100644 --- a/storage/local/persistence_test.go +++ b/storage/local/persistence_test.go @@ -884,3 +884,74 @@ func verifyIndexedState(i int, t *testing.T, b incrementalBatch, indexedFpsToMet } } } + +var fpStrings = []string{ + "b004b821ca50ba26", + "b037c21e884e4fc5", + "b037de1e884e5469", +} + +func BenchmarkLoadChunksSequentially(b *testing.B) { + p := persistence{ + basePath: "fixtures", + } + sequentialIndexes := make([]int, 47) + for i := range sequentialIndexes { + sequentialIndexes[i] = i + } + + var fp clientmodel.Fingerprint + for i := 0; i < b.N; i++ { + for _, s := range fpStrings { + fp.LoadFromString(s) + cds, err := p.loadChunks(fp, sequentialIndexes, 0) + if err != nil { + b.Error(err) + } + if len(cds) == 0 { + b.Error("could not read any chunks") + } + } + } +} + +func BenchmarkLoadChunksRandomly(b *testing.B) { + p := persistence{ + basePath: "fixtures", + } + randomIndexes := []int{1, 5, 6, 8, 11, 14, 18, 23, 29, 33, 42, 46} + + var fp clientmodel.Fingerprint + for i := 0; i < b.N; i++ { + for _, s := range fpStrings { + fp.LoadFromString(s) + cds, err := p.loadChunks(fp, randomIndexes, 0) + if err != nil { + b.Error(err) + } + if len(cds) == 0 { + b.Error("could not read any chunks") + } + } + } +} + +func BenchmarkLoadChunkDescs(b *testing.B) { + p := persistence{ + basePath: "fixtures", + } + + var fp clientmodel.Fingerprint + for i := 0; i < b.N; i++ { + for _, s := range fpStrings { + fp.LoadFromString(s) + cds, err := p.loadChunkDescs(fp, clientmodel.Latest) + if err != nil { + b.Error(err) + } + if len(cds) == 0 { + b.Error("could not read any chunk descs") + } + } + } +}