From 4b9825d8aae7b1e933753ba71a533d639768945a Mon Sep 17 00:00:00 2001 From: Jose Hugo De la cruz Romero Date: Tue, 17 Dec 2019 11:50:54 -0600 Subject: [PATCH] =?UTF-8?q?Decoded=20string,=20and=20added=20new=20regest?= =?UTF-8?q?=20to=20match=20=C2=B5s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- evm/scripts/benchevm.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/evm/scripts/benchevm.py b/evm/scripts/benchevm.py index 34098c1..68ad42c 100644 --- a/evm/scripts/benchevm.py +++ b/evm/scripts/benchevm.py @@ -121,19 +121,25 @@ def do_geth_bench(geth_cmd): print("running geth-evm benchmark...\n{}\n".format(geth_cmd)) geth_cmd = shlex.split(geth_cmd) stdoutlines = [] - with subprocess.Popen(geth_cmd, cwd=GETH_EVM_DIR, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, bufsize=1, universal_newlines=True) as p: + with subprocess.Popen(geth_cmd, cwd=GETH_EVM_DIR, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, bufsize=1) as p: for line in p.stdout: # b'\n'-separated lines - print(line, end='') - stdoutlines.append(line) # pass bytes as is + print(line.decode(), end='') + stdoutlines.append(line.decode()) # pass bytes as is p.wait() - nsOpRegex = "evm execution time: ([\d]+.[\d]+)ms" + msOpRegex = "evm execution time: ([\d]+.[\d]+)ms" + qsOpRegex = "evm execution time: ([\d]+.[\d]+)µs" gasregex = "Gas used:\s+(\d+)" # maybe --benchmark_format=json is better so dont have to parse "36.775k" time_line = stdoutlines[0] gas_line = stdoutlines[-3] - time_match = re.search(nsOpRegex, time_line) - time = durationpy.from_str("{}ms".format(time_match.group(1))) + time_match = re.search(msOpRegex, time_line) + time = None + if time_match == None: + time_match = re.search(qsOpRegex, time_line) + time = durationpy.from_str("{}µs".format(time_match.group(1))) + else: + time = durationpy.from_str("{}ms".format(time_match.group(1))) gas_match = re.search(gasregex, gas_line) gasused = gas_match.group(1) return {'gas_used': gasused, 'time': time.total_seconds()}