...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package mvcc
16
17 import (
18 "testing"
19
20 "go.uber.org/zap"
21 )
22
23 func BenchmarkIndexCompact1(b *testing.B) { benchmarkIndexCompact(b, 1) }
24 func BenchmarkIndexCompact100(b *testing.B) { benchmarkIndexCompact(b, 100) }
25 func BenchmarkIndexCompact10000(b *testing.B) { benchmarkIndexCompact(b, 10000) }
26 func BenchmarkIndexCompact100000(b *testing.B) { benchmarkIndexCompact(b, 100000) }
27 func BenchmarkIndexCompact1000000(b *testing.B) { benchmarkIndexCompact(b, 1000000) }
28
29 func benchmarkIndexCompact(b *testing.B, size int) {
30 log := zap.NewNop()
31 kvindex := newTreeIndex(log)
32
33 bytesN := 64
34 keys := createBytesSlice(bytesN, size)
35 for i := 1; i < size; i++ {
36 kvindex.Put(keys[i], revision{main: int64(i), sub: int64(i)})
37 }
38 b.ResetTimer()
39 for i := 1; i < b.N; i++ {
40 kvindex.Compact(int64(i))
41 }
42 }
43
View as plain text