diff options
author | Ben Johnson <benbjohnson@yahoo.com> | 2014-04-18 21:37:45 -0500 |
---|---|---|
committer | Ben Johnson <benbjohnson@yahoo.com> | 2014-04-18 22:15:31 -0500 |
commit | a42d74da7e6b3162701ae17d59647a6880ccb6bf (patch) | |
tree | b32ca009bfaeae67cc0db5e388ba574b07cfa333 /cmd/bolt/generate.go | |
parent | move bench package to bench/cmd/bolt/bench (diff) | |
download | dedo-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 'cmd/bolt/generate.go')
-rw-r--r-- | cmd/bolt/generate.go | 55 |
1 files changed, 0 insertions, 55 deletions
diff --git a/cmd/bolt/generate.go b/cmd/bolt/generate.go deleted file mode 100644 index 15edb27..0000000 --- a/cmd/bolt/generate.go +++ /dev/null @@ -1,55 +0,0 @@ -package main - -import ( - "fmt" - - "github.com/boltdb/bolt" -) - -// Generate data for benchmarks. -func Generate(destPath string, numBuckets, numItems int) { - - // Open the database. - db, err := bolt.Open(destPath, 0600) - if err != nil { - fatalf("open db:", err) - return - } - defer db.Close() - - for bucketIndex := 0; bucketIndex < numBuckets; bucketIndex++ { - bucketName := fmt.Sprintf("bucket%03d", bucketIndex) - - err = db.Update(func(tx *bolt.Tx) error { - - // Create the bucket if it doesn't exist. - if err := tx.CreateBucketIfNotExists([]byte(bucketName)); err != nil { - fatalf("create bucket: %s", err) - return nil - } - - // Find bucket. - b := tx.Bucket([]byte(bucketName)) - if b == nil { - fatalf("bucket not found: %s", bucketName) - return nil - } - - for i := 0; i < numItems; i++ { - key := fmt.Sprintf("key%03d", i) - value := fmt.Sprintf("value%03d", i) - - // Set value for a given key. - if err := b.Put([]byte(key), []byte(value)); err != nil { - return err - } - } - - return nil - }) - } - if err != nil { - fatal(err) - return - } -} |