Skip to content

Instantly share code, notes, and snippets.

@inv2004
Last active September 23, 2018 03:53
Show Gist options
  • Save inv2004/d8e397ee7d0553940b60dff7f3005540 to your computer and use it in GitHub Desktop.
Save inv2004/d8e397ee7d0553940b60dff7f3005540 to your computer and use it in GitHub Desktop.
package main
import (
"time"
"github.com/globalsign/mgo"
"time"
"github.com/globalsign/mgo"
)
func initDb() (*mgo.Session, error) {
session, err := mgo.Dial("mongodb://localhost:27017/")
if err != nil {
return nil, err
}
return session, nil
}
func main() {
session, err := initDb()
if err != nil {
println(err.Error())
}
doc := map[string]interface{}{"type" : "done", "order_id" : "a5cce297-3533-4032-917a-98e7cee4820b", "reason" :r}
start := time.Now()
for i := 0; i < 1000; i++ {
err := session.DB("test_bench").C("TEST2").Insert(doc)
if err != nil {
println(err.Error())
}
}
elapsed := time.Since(start)
println(elapsed);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment