diff options
author | Ben Johnson <benbjohnson@yahoo.com> | 2014-04-10 13:58:21 -0600 |
---|---|---|
committer | Ben Johnson <benbjohnson@yahoo.com> | 2014-04-10 13:58:21 -0600 |
commit | e9c8f14d88c9a25c8bc4b568a9b74b9a65c642f5 (patch) | |
tree | 6f6785b4a0470b926ba9315fcc16b00ee9f859c4 /db_test.go | |
parent | Merge pull request #123 from Shopify/commit_in_binary (diff) | |
parent | make all benchmarks constant size and add multiple sizes (diff) | |
download | dedo-e9c8f14d88c9a25c8bc4b568a9b74b9a65c642f5.tar.gz dedo-e9c8f14d88c9a25c8bc4b568a9b74b9a65c642f5.tar.xz |
Merge pull request #122 from mkobetic/benchmark_tweaks
Make all benchmarks constant size and add multiple sizes
Diffstat (limited to 'db_test.go')
-rw-r--r-- | db_test.go | 34 |
1 files changed, 0 insertions, 34 deletions
@@ -5,11 +5,8 @@ import ( "flag" "fmt" "io/ioutil" - "math/rand" "os" "regexp" - "strconv" - "strings" "testing" "time" "unsafe" @@ -322,37 +319,6 @@ func TestDBString(t *testing.T) { assert.Equal(t, db.GoString(), `bolt.DB{path:"/tmp/foo"}`) } -// Benchmark the performance of single put transactions in random order. -func BenchmarkDBPutSequential(b *testing.B) { - value := []byte(strings.Repeat("0", 64)) - withOpenDB(func(db *DB, path string) { - db.Update(func(tx *Tx) error { - return tx.CreateBucket("widgets") - }) - for i := 0; i < b.N; i++ { - db.Update(func(tx *Tx) error { - return tx.Bucket("widgets").Put([]byte(strconv.Itoa(i)), value) - }) - } - }) -} - -// Benchmark the performance of single put transactions in random order. -func BenchmarkDBPutRandom(b *testing.B) { - indexes := rand.Perm(b.N) - value := []byte(strings.Repeat("0", 64)) - withOpenDB(func(db *DB, path string) { - db.Update(func(tx *Tx) error { - return tx.CreateBucket("widgets") - }) - for i := 0; i < b.N; i++ { - db.Update(func(tx *Tx) error { - return tx.Bucket("widgets").Put([]byte(strconv.Itoa(indexes[i])), value) - }) - } - }) -} - // withTempPath executes a function with a database reference. func withTempPath(fn func(string)) { f, _ := ioutil.TempFile("", "bolt-") |