Skip to content

Instantly share code, notes, and snippets.

@zookos
Created December 9, 2010 20:25
Show Gist options
  • Save zookos/735278 to your computer and use it in GitHub Desktop.
Save zookos/735278 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
from pyutil import benchutil
def meas(N, cand):
for i in range(N):
r = cand == 'x'*32
def meas_right(N):
return meas(N, 'x'*32)
def meas_wrong(N):
return meas(N, 'y'*32)
print "nanoseconds to == with the right query string: "
benchutil.rep_bench(meas_right, 10**3, MAXREPS=100, UNITS_PER_SECOND=10**9)
benchutil.print_bench_footer(UNITS_PER_SECOND=10**9)
print
print "nanoseconds to == with the wrong query string: "
benchutil.rep_bench(meas_wrong, 10**3, MAXREPS=100, UNITS_PER_SECOND=10**9)
benchutil.print_bench_footer(UNITS_PER_SECOND=10**9)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment