Small fixups to benchmarking

This commit is contained in:
Jason Paryani
2013-11-18 13:17:49 -08:00
parent 895f74547c
commit d6df2bc98b

View File

@@ -1,4 +1,5 @@
#!/usr/bin/env python #!/usr/bin/env python
from __future__ import print_function
from subprocess import Popen, PIPE from subprocess import Popen, PIPE
import sys import sys
@@ -8,7 +9,7 @@ import argparse
def parse_args(): def parse_args():
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.add_argument('-l', "--langs", help="Add languages to test with the form: pycapnp:pycapnp", action='append', default=['pycapnp', 'pyproto', 'pyproto_cpp']) parser.add_argument('-l', "--langs", help="Add languages to test, ie: -l capnproto -l protobuf", action='append', default=['pycapnp', 'pyproto', 'pyproto_cpp'])
parser.add_argument("-r", "--reuse", help="If this flag is passed, re-use tests will be run", action='store_true',) parser.add_argument("-r", "--reuse", help="If this flag is passed, re-use tests will be run", action='store_true',)
parser.add_argument("-c", "--compression", help="If this flag is passed, compression tests will be run", action='store_true') parser.add_argument("-c", "--compression", help="If this flag is passed, compression tests will be run", action='store_true')
parser.add_argument("-i", "--scale_iters", help="Scaling factor to multiply the default iters by", type=float, default=1.0) parser.add_argument("-i", "--scale_iters", help="Scaling factor to multiply the default iters by", type=float, default=1.0)
@@ -25,10 +26,16 @@ def run_cpp(prefix, name, mode, iters, faster, compression):
if compression != 'none': if compression != 'none':
res_type += '_' + compression res_type += '_' + compression
p = Popen(["time", "-p", prefix+"-"+name, mode, reuse, compression, str(iters)], stdout=PIPE, stderr=PIPE) command = ["time", "-p", prefix+"-"+name, mode, reuse, compression, str(iters)]
p = Popen(command, stdout=PIPE, stderr=PIPE)
res = p.communicate()[1] res = p.communicate()[1]
data = {} data = {}
if p.returncode != 0:
sys.stderr.write(' '.join(command) + ' failed to run with errors: ' + res + '\n')
sys.stderr.flush()
else:
res = res.strip() res = res.strip()
for line in res.split('\n'): for line in res.split('\n'):
@@ -62,7 +69,6 @@ def run_each(name, langs, reuse, compression, iters):
def main(): def main():
args = parse_args() args = parse_args()
del os.environ['PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION']
os.environ['PATH'] += ':.' os.environ['PATH'] += ':.'
data = [] data = []