Skip to content

Instantly share code, notes, and snippets.

@wwoods
Created October 24, 2013 23:03
Show Gist options
  • Save wwoods/7146660 to your computer and use it in GitHub Desktop.
Save wwoods/7146660 to your computer and use it in GitHub Desktop.
from __future__ import print_function
import copy
import hyperclient
import pymongo
import time
import rethinkdb as r
class DbTest(object):
def setup(self):
pass
def test(self):
pass
def run(self):
print("{}: ".format(self.__class__.__name__), end = "")
self.setup()
self.docs = [ { 'val': i, 'count': 8, 'data': [ 1, 2, 3, 4, 5 ] * 20 }
for i in range(100000) ]
a = time.time()
self.test()
b = time.time()
print("{:.2f}".format(b - a))
class HyperdexTest(DbTest):
def setup(self):
self.c = c = hyperclient.Client('127.0.0.1', 1982)
try:
c.rm_space('speedtest')
except hyperclient.HyperClientException:
pass
c.add_space('''
space speedtest
key id
attributes
int val,
int count,
list(int) data
''')
def test(self):
for d in self.docs:
self.c.put('speedtest', d['val'], d)
class MongoDbTest(DbTest):
def setup(self):
self.mc = pymongo.MongoClient(fsync = True)['test']['test']
self.mc.remove()
def test(self):
self.mc.insert(self.docs)
class RethinkDbTest(DbTest):
def setup(self):
self.rc = rc = r.connect()
r.db_drop('test').run(rc, noreply = True)
r.db_create('test').run(rc)
r.db('test').table_create('test').run(rc)
def test(self):
r.db('test').table('test').insert(self.docs).run(self.rc)
MongoDbTest().run()
RethinkDbTest().run()
HyperdexTest().run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment