In [5]:
import os
import subprocess
from time import time
def bench(cmd, reps=10):
times = []
for i in range(reps):
s = time()
subprocess.call(cmd)
d = time() - s
times.append(d)
print('{:02d}. {:0.3f}s'.format(i + 1, d))
av = sum(times) / float(reps)
print('-' * 15)
print('{:0.3f}s/run'.format(av))
In [6]:
REPS = 10
QUERY = 'quimby'
In [7]:
bench(['../src/searchio', 'search', 'google-en', QUERY], REPS)
In [8]:
bench(['../src/search', 'google-en', QUERY], REPS)