Skip to content

Instantly share code, notes, and snippets.

@tsyber1an
Forked from coffeemug/gist:6444786
Created September 28, 2013 11:20
Show Gist options
  • Save tsyber1an/6741077 to your computer and use it in GitHub Desktop.
Save tsyber1an/6741077 to your computer and use it in GitHub Desktop.
"""Compares rethinkdb with mongo. Copied from http://pastebin.com/3PqdFTjc. Example output:
mongodb: 0.110867023468
rethink: 2.25043606758
"""
import copy
import pymongo
import rethinkdb as r
import time
mc = pymongo.Connection()
rc = r.connect()
mc.drop_database('test')
r.db_drop('test').run(rc, noreply = True)
r.db_create('test').run(rc)
r.db('test').table_create('test').run(rc)
mcol = mc['test']['test']
rcol = r.db('test').table('test')
_docs = [ { 'val': i, 'count': 8, 'data': [ 1, 2, 3, 4, 5 ] * 20 }
for i in range(1000) ]
mdocs = copy.deepcopy(_docs)
rdocs = copy.deepcopy(_docs)
def timeit(c, l):
a = time.time()
l()
print("{}: {}".format(c, time.time() - a))
timeit("mongodb", lambda: mcol.insert(mdocs, safe = True))
timeit("rethink", lambda: rcol.insert(rdocs).run(rc))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment