Skip to content

Instantly share code, notes, and snippets.

@marvin
Created December 13, 2012 23:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marvin/4281028 to your computer and use it in GitHub Desktop.
Save marvin/4281028 to your computer and use it in GitHub Desktop.
tiny mongodb benchmark btw python and go
package main
import (
"labix.org/v2/mgo"
"strconv"
)
type Data struct {
Data string
}
func main() {
session, err := mgo.Dial("localhost")
if err != nil {
panic(err)
}
defer session.Close()
c := session.DB("test").C("data")
for i := 0; i < 10000; i++ {
data := "Test" + strconv.Itoa(i)
err = c.Insert(&Data{data})
if err != nil {
panic(err)
}
}
}
from pymongo import Connection
connection = Connection()
db = connection.test
collection = db.data
for i in range(10001):
post = {"name": "Test"+str(i)}
collection.insert(post)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment