Skip to content

Instantly share code, notes, and snippets.

@ysmood
Last active March 26, 2020 05:32
Show Gist options
  • Save ysmood/a18af48010b08a39886ef460f98fddaf to your computer and use it in GitHub Desktop.
Save ysmood/a18af48010b08a39886ef460f98fddaf to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"time"
"github.com/ysmood/kit"
"github.com/ysmood/storer"
"github.com/ysmood/storer/pkg/kvstore"
)
type binData []byte
func main() {
kit.E(kit.Remove("db-dir"))
db := storer.New("db-dir")
list := db.List(&binData{})
buf := binData("0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000")
data := make([]int, 100000)
for i := 0; i < 10; i++ {
start := time.Now()
kit.E(db.Update(func(txn kvstore.Txn) error {
for range data {
_, err := list.Txn(txn).Add(&buf)
kit.E(err)
}
return nil
}))
fmt.Println(time.Since(start))
}
}
// 289.866707ms
// 323.015396ms
// 303.124774ms
// 305.227971ms
// 338.302816ms
// 321.402501ms
// 319.549729ms
// 334.101525ms
// 332.849792ms
// 350.83629ms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment