Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Rework Python encode/decode benchmarks to work with harness

  • Loading branch information...
commit 8cc212a2af8ec215695aef0e015616ef12857264 1 parent 9636fda
@bos authored
Showing with 22 additions and 2 deletions.
  1. +11 −1 benchmarks/encode.py
  2. +11 −1 benchmarks/parse.py
View
12 benchmarks/encode.py
@@ -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:]:
@@ -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)
View
12 benchmarks/parse.py
@@ -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:]:
@@ -12,4 +22,4 @@
fp.seek(0)
val = json.load(fp)
end = time.time()
- print ' ', end - start
+ print ' %d good, %gs' % (count, end - start)
Please sign in to comment.
Something went wrong with that request. Please try again.