$ benchstat goLevelDB.txt badgerDB.txt
name old time/op new time/op delta
SetDelete-4 32.8ms ±19% 3.6ms ±22% -88.97% (p=0.000 n=10+9)
name old alloc/op new alloc/op delta
SetDelete-4 24.0MB ± 0% 6.3MB ± 3% -73.91% (p=0.000 n=10+9)
name old allocs/op new allocs/op delta
SetDelete-4 332 ± 1% 251 ± 0% -24.37% (p=0.000 n=9+7)
Last active
November 6, 2017 02:26
-
-
Save odeke-em/96b8a012462396d589ed2f05b5253068 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BenchmarkSetDelete-4 500 4017796 ns/op 6318207 B/op 251 allocs/op | |
BenchmarkSetDelete-4 20 50002573 ns/op 5196896 B/op 237 allocs/op | |
BenchmarkSetDelete-4 500 4189012 ns/op 6318139 B/op 251 allocs/op | |
BenchmarkSetDelete-4 500 4028421 ns/op 6319832 B/op 251 allocs/op | |
BenchmarkSetDelete-4 300 3419728 ns/op 6076823 B/op 250 allocs/op | |
BenchmarkSetDelete-4 500 2828081 ns/op 6318151 B/op 251 allocs/op | |
BenchmarkSetDelete-4 1000 3638473 ns/op 6217322 B/op 251 allocs/op | |
BenchmarkSetDelete-4 500 3446303 ns/op 6319831 B/op 251 allocs/op | |
BenchmarkSetDelete-4 1000 3779531 ns/op 6218172 B/op 252 allocs/op | |
BenchmarkSetDelete-4 500 3234770 ns/op 6318151 B/op 251 allocs/op |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package db_test | |
import ( | |
"fmt" | |
"os" | |
"path/filepath" | |
"testing" | |
cmn "github.com/tendermint/tmlibs/common" | |
"github.com/tendermint/tmlibs/db" | |
) | |
var benchmarkData = []struct { | |
key, value []byte | |
}{ | |
{cmn.RandBytes(100), nil}, | |
{cmn.RandBytes(1000), []byte("foo")}, | |
{[]byte("foo"), cmn.RandBytes(1000)}, | |
{[]byte(""), cmn.RandBytes(1000)}, | |
{nil, cmn.RandBytes(1000000)}, | |
{cmn.RandBytes(100000), nil}, | |
{cmn.RandBytes(1000000), nil}, | |
} | |
func benchmarkBatchSetDelete(b *testing.B, db db.DB) { | |
b.ResetTimer() | |
batch := db.NewBatch() | |
for i := 0; i < b.N; i++ { | |
for _, tt := range benchmarkData { | |
batch.Set(tt.key, tt.value) | |
} | |
batch.Write() | |
for _, tt := range benchmarkData { | |
batch.Delete(tt.key) | |
} | |
} | |
b.ReportAllocs() | |
} | |
func BenchmarkSetDeleteBadgerDB(b *testing.B) { | |
ddb, tearDown := setupBadgerDB(nil) | |
defer tearDown() | |
benchmarkSetDelete(b, ddb) | |
} | |
func setupBadgerDB(t *testing.T) (d db.DB, tearDown func()) { | |
testDir, err := ioutil.TempDir("", "throwaway-db-tests") | |
require.Nil(t, err, "expecting a nil error") | |
ddb := db.NewDB("test_db", db.BadgerDBBackendStr, testDir) | |
tearDown = func() { | |
ddb.Close() | |
os.RemoveAll(testDir) | |
} | |
return ddb, tearDown | |
} | |
func BenchmarkBatchSetDeleteGoLevelDB(b *testing.B) { | |
ddb, tearDown, err := setupGoLevelDB() | |
if err != nil { | |
b.Fatal(err) | |
} | |
defer tearDown() | |
benchmarkBatchSetDelete(b, ddb) | |
} | |
func setupGoLevelDB() (db.DB, func() error, error) { | |
dir := "golevel_db_test" | |
dirPrefix := filepath.Join(dir, fmt.Sprintf("%x", cmn.RandStr(12))) | |
db, err := db.NewGoLevelDB(dirPrefix, "") | |
if err != nil { | |
return nil, nil, err | |
} | |
tearDown := func() error { return os.RemoveAll(dir) } | |
return db, tearDown, nil | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BenchmarkSetDelete-4 100 30669959 ns/op 24072977 B/op 339 allocs/op | |
BenchmarkSetDelete-4 100 29415932 ns/op 24069500 B/op 336 allocs/op | |
BenchmarkSetDelete-4 100 33665902 ns/op 23961585 B/op 333 allocs/op | |
BenchmarkSetDelete-4 100 39121196 ns/op 23961514 B/op 333 allocs/op | |
BenchmarkSetDelete-4 100 29912327 ns/op 24057952 B/op 332 allocs/op | |
BenchmarkSetDelete-4 100 31123865 ns/op 24057897 B/op 331 allocs/op | |
BenchmarkSetDelete-4 100 33631460 ns/op 23961279 B/op 331 allocs/op | |
BenchmarkSetDelete-4 100 35382145 ns/op 24057800 B/op 330 allocs/op | |
BenchmarkSetDelete-4 100 37973039 ns/op 24057850 B/op 331 allocs/op | |
BenchmarkSetDelete-4 100 27349653 ns/op 24066879 B/op 330 allocs/op |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment