-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdb_bench_test.go
More file actions
39 lines (37 loc) · 827 Bytes
/
db_bench_test.go
File metadata and controls
39 lines (37 loc) · 827 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package mbbolt
import (
"context"
"strconv"
"sync/atomic"
"testing"
)
func BenchmarkNoFreelistSync(b *testing.B) {
b.Run("True", func(b *testing.B) {
tmp := b.TempDir()
opts := *DefaultOptions
opts.NoFreelistSync = true
db := NewSegDB(context.Background(), tmp, ".db", &opts, 32)
defer db.Close()
var x atomic.Int64
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
i := x.Add(1)
db.Put("bkt", strconv.FormatInt(i, 10), i)
}
})
})
b.Run("False", func(b *testing.B) {
tmp := b.TempDir()
opts := *DefaultOptions
opts.NoFreelistSync = false
db := NewSegDB(context.Background(), tmp, ".db", &opts, 32)
defer db.Close()
var x atomic.Int64
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
i := x.Add(1)
db.Put("bkt", strconv.FormatInt(i, 10), i)
}
})
})
}