aboutsummaryrefslogtreecommitdiff
path: root/db_test.go
diff options
context:
space:
mode:
authorBen Johnson <benbjohnson@yahoo.com>2014-04-18 21:37:45 -0500
committerBen Johnson <benbjohnson@yahoo.com>2014-04-18 22:15:31 -0500
commita42d74da7e6b3162701ae17d59647a6880ccb6bf (patch)
treeb32ca009bfaeae67cc0db5e388ba574b07cfa333 /db_test.go
parentmove bench package to bench/cmd/bolt/bench (diff)
downloaddedo-a42d74da7e6b3162701ae17d59647a6880ccb6bf.tar.gz
dedo-a42d74da7e6b3162701ae17d59647a6880ccb6bf.tar.xz
Add 'bolt bench'.
This commit adds a flexible benchmarking tool to the 'bolt' CLI. It allows the user to separately specify the write mode and read mode (e.g. sequential random, etc). It also allows the user to isolate profiling to either the read or the writes. Currently the bench tool only supports "seq" read and write modes. It also does not support streaming of Bolt counters yet. Fixes #95. /cc @snormore
Diffstat (limited to 'db_test.go')
-rw-r--r--db_test.go36
1 files changed, 0 insertions, 36 deletions
diff --git a/db_test.go b/db_test.go
index baef98e..57c356e 100644
--- a/db_test.go
+++ b/db_test.go
@@ -5,11 +5,8 @@ import (
"flag"
"fmt"
"io/ioutil"
- "math/rand"
"os"
"regexp"
- "strconv"
- "strings"
"testing"
"time"
"unsafe"
@@ -356,39 +353,6 @@ func TestDBStats_Sub(t *testing.T) {
assert.Equal(t, 7, diff.TxStats.PageCount)
}
-// Benchmark the performance of single put transactions in random order.
-func BenchmarkDB_Put_Sequential(b *testing.B) {
- value := []byte(strings.Repeat("0", 64))
- withOpenDB(func(db *DB, path string) {
- db.Update(func(tx *Tx) error {
- _, err := tx.CreateBucket([]byte("widgets"))
- return err
- })
- for i := 0; i < b.N; i++ {
- db.Update(func(tx *Tx) error {
- return tx.Bucket([]byte("widgets")).Put([]byte(strconv.Itoa(i)), value)
- })
- }
- })
-}
-
-// Benchmark the performance of single put transactions in random order.
-func BenchmarkDB_Put_Random(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 {
- _, err := tx.CreateBucket([]byte("widgets"))
- return err
- })
- for i := 0; i < b.N; i++ {
- db.Update(func(tx *Tx) error {
- return tx.Bucket([]byte("widgets")).Put([]byte(strconv.Itoa(indexes[i])), value)
- })
- }
- })
-}
-
func ExampleDB_Update() {
// Open the database.
db, _ := Open(tempfile(), 0666)