Last active
March 30, 2019 18:05
-
-
Save mattn/3990033f7bc8a57cd5b86edefb254332 to your computer and use it in GitHub Desktop.
benchmark with bolt, goleveldb, pogreb for writing
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 main | |
| import ( | |
| "fmt" | |
| "log" | |
| "github.com/boltdb/bolt" | |
| ) | |
| func main() { | |
| db, err := bolt.Open("boltdb", 0600, nil) | |
| if err != nil { | |
| log.Fatal(err) | |
| } | |
| defer db.Close() | |
| db.Update(func(tx *bolt.Tx) error { | |
| b, err := tx.CreateBucketIfNotExists([]byte("MyBucket")) | |
| if err != nil { | |
| return err | |
| } | |
| for i := 0; i < 100000; i++ { | |
| b.Put([]byte(fmt.Sprintf("foo%06d", i)), []byte("bar")) | |
| } | |
| return 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
| package main | |
| import ( | |
| "fmt" | |
| "log" | |
| "github.com/syndtr/goleveldb/leveldb" | |
| ) | |
| func main() { | |
| db, err := leveldb.OpenFile("goleveldb", nil) | |
| if err != nil { | |
| log.Fatal(err) | |
| } | |
| defer db.Close() | |
| for i := 0; i < 100000; i++ { | |
| db.Put([]byte(fmt.Sprintf("foo%06d", i)), []byte("bar"), 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
| package main | |
| import ( | |
| "fmt" | |
| "log" | |
| "github.com/akrylysov/pogreb" | |
| ) | |
| func main() { | |
| db, err := pogreb.Open("pogrebdb", nil) | |
| if err != nil { | |
| log.Fatal(err) | |
| } | |
| defer db.Close() | |
| for i := 0; i < 100000; i++ { | |
| db.Put([]byte(fmt.Sprintf("foo%06d", i)), []byte("bar")) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Keep in mind Pogreb v0.8 doubled write performance on non-Windows.