Skip to content

Commit

Permalink
Rework Python encode/decode benchmarks to work with harness
Browse files Browse the repository at this point in the history
  • Loading branch information
bos committed Jan 9, 2014
1 parent 9636fda commit 8cc212a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
12 changes: 11 additions & 1 deletion benchmarks/encode.py
Expand Up @@ -2,6 +2,16 @@

import json, sys, time

def isint(x):
try:
int(x)
return True
except:
return False

if len(sys.argv) > 2 and isint(sys.argv[1]) and isint(sys.argv[2]):
sys.argv.pop(1)

count = int(sys.argv[1])

for n in sys.argv[2:]:
Expand All @@ -11,4 +21,4 @@
for i in xrange(count):
json.dumps(obj)
end = time.time()
print ' ', end - start
print ' %d good, %gs' % (count, end - start)
12 changes: 11 additions & 1 deletion benchmarks/parse.py
Expand Up @@ -2,6 +2,16 @@

import json, sys, time

def isint(x):
try:
int(x)
return True
except:
return False

if len(sys.argv) > 2 and isint(sys.argv[1]) and isint(sys.argv[2]):
sys.argv.pop(1)

count = int(sys.argv[1])

for n in sys.argv[2:]:
Expand All @@ -12,4 +22,4 @@
fp.seek(0)
val = json.load(fp)
end = time.time()
print ' ', end - start
print ' %d good, %gs' % (count, end - start)

0 comments on commit 8cc212a

Please sign in to comment.