Skip to content

Commit

Permalink
[feature] modify test case
Browse files Browse the repository at this point in the history
  • Loading branch information
waldoweng committed Oct 12, 2019
1 parent dbd70fe commit 7cd5d5c
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions storage/bitcask_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,22 +206,29 @@ func BenchmarkBitcask_RandomReadWrite(benchmark *testing.B) {
}

func BenchmarkBitcask_ConcurrentWrite(benchmark *testing.B) {
benchmark.SetParallelism(20)
benchmark.RunParallel(func(pb *testing.PB) {
var i int32
for pb.Next() {
atomic.AddInt32(&i, 1)
b.Set(fmt.Sprintf("benchmark concurrent write key %d", i), fmt.Sprintf("benchmark concurrent write value %d", i))
}
})
benchFunc := func(benchmark *testing.B, parallelism int) {
benchmark.SetParallelism(parallelism)
benchmark.RunParallel(func(pb *testing.PB) {
var i int32
for pb.Next() {
atomic.AddInt32(&i, 1)
b.Set(fmt.Sprintf("benchmark concurrent write key %d", i), fmt.Sprintf("benchmark concurrent write value %d", i))
}
})
}

benchmark.Run("parallelism = 5", func(benchmark *testing.B) { benchFunc(benchmark, 5) })
benchmark.Run("parallelism = 10", func(benchmark *testing.B) { benchFunc(benchmark, 10) })
benchmark.Run("parallelism = 30", func(benchmark *testing.B) { benchFunc(benchmark, 30) })
benchmark.Run("parallelism = 100", func(benchmark *testing.B) { benchFunc(benchmark, 100) })
}

func TestMain(m *testing.M) {
log.SetFlags(log.Ltime | log.Lshortfile)
b = NewBitcask(CreateOption{
MaxKeySize: 1024,
MaxValueSize: 1024 * 1024,
CompactSize: 128 * 1024,
CompactSize: 512 * 1024 * 1024,
})
result := m.Run()
b.Destory()
Expand Down

0 comments on commit 7cd5d5c

Please sign in to comment.