Created
January 7, 2015 10:55
-
-
Save ketuls/45ffd74d3c9c6d14e3d3 to your computer and use it in GitHub Desktop.
This file reads the data inserted by couchdb_generate.py. Time required to read the data is printed on terminal. Sample command would be "python couchdb_reader.py <# of records inserted> <# of records to be fetched>".
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
import json | |
import md5 | |
import couchdb | |
import random | |
import sys | |
import couchdbkit | |
from datetime import datetime | |
count = int(sys.argv[1]); | |
query = int(sys.argv[2]); | |
couch = couchdb.Server() | |
db_name='test'+str(count) | |
db = couch[db_name] | |
startTime = datetime.now() | |
m = [] | |
for i in range(query): | |
m.append(md5.md5(str(random.randint(10,count-10))).hexdigest()) | |
queryTime = datetime.now() | |
rows = db.view('_all_docs', keys=m, include_docs=True) | |
print("Query Time is ") | |
print datetime.now() - queryTime | |
for row in rows: | |
row | |
print("Read Time is ") | |
print datetime.now() - queryTime | |
print("Script Tme is ") | |
print datetime.now() - startTime |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment