Twisted benchmark reporting crashes when runner is Python3
This is used in benchmarks.py
to parse the output of twisted benchmarks
def _register_new_bm_twisted(name, bm_name, d, **opts):
def Measure(python, options):
def parser(line):
number = float(line.split(b" ")[0])
if name == 'tcp':
return 100*1024*1024/number
elif name == 'iteration':
return 10000/number
else:
return 100/number
bm_path = relative('own', 'twisted', name + '.py')
return MeasureGeneric(python, options, bm_path, parser=parser, **opts)
In particular, the line float(line.split(b" ")[0])
will error when the runner is Python 3, since the line is a unicode object coming from subprocess.Popen
:
File "/b/b/e/main/pypy-suite-work.kacrk5py/benchmarks/unladen_swallow/perf.py", line 828, in <listcomp>
times = [parser(line) for line in result.splitlines()]
File "/b/b/e/main/pypy-suite-work.kacrk5py/benchmarks/benchmarks.py", line 28, in parser
number = float(line.split(b" ")[0])
TypeError: must be str or None, not bytes
I don't see why the argument to split
is needed at all - the default whitespace split should be fine, since if we want to parse a float, we're not expecting other whitespaces to be contained in the first element anyway.
I propose changing float(line.split(b" ")[0])
to simply float(line.split()[0])