Created
October 24, 2013 23:03
-
-
Save wwoods/7146660 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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