File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed
Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change 44 "errors"
55 "math/rand"
66 "os"
7+ "runtime"
78 "testing"
89
910 "github.com/rosedblabs/rosedb/v2"
@@ -15,7 +16,12 @@ var db *rosedb.DB
1516
1617func openDB () func () {
1718 options := rosedb .DefaultOptions
18- options .DirPath = "/tmp/rosedbv2"
19+ sysType := runtime .GOOS
20+ if sysType == "windows" {
21+ options .DirPath = "C:\\ rosedb_bench_test"
22+ } else {
23+ options .DirPath = "/tmp/rosedb_bench_test"
24+ }
1925
2026 var err error
2127 db , err = rosedb .Open (options )
@@ -60,7 +66,9 @@ func benchmarkBatchPut(b *testing.B) {
6066 b .ReportAllocs ()
6167
6268 batch := db .NewBatch (rosedb .DefaultBatchOptions )
63- defer batch .Commit ()
69+ defer func () {
70+ _ = batch .Commit ()
71+ }()
6472 for i := 0 ; i < b .N ; i ++ {
6573 err := batch .Put (utils .GetTestKey (i ), utils .RandomValue (1024 ))
6674 assert .Nil (b , err )
@@ -76,7 +84,9 @@ func benchmarkBatchGet(b *testing.B) {
7684 b .ResetTimer ()
7785 b .ReportAllocs ()
7886 batch := db .NewBatch (rosedb .DefaultBatchOptions )
79- defer batch .Commit ()
87+ defer func () {
88+ _ = batch .Commit ()
89+ }()
8090 for i := 0 ; i < b .N ; i ++ {
8191 _ , err := batch .Get (utils .GetTestKey (rand .Int ()))
8292 if err != nil && ! errors .Is (err , rosedb .ErrKeyNotFound ) {
You can’t perform that action at this time.
0 commit comments