summaryrefslogtreecommitdiff
path: root/tools/util.py
diff options
context:
space:
mode:
authorBernard Lin <bernardlin12@gmail.com>2019-03-24 23:36:27 -0400
committerRyan Dahl <ry@tinyclouds.org>2019-03-24 23:36:27 -0400
commit3cc90d9bcf4be58bf88b433ae410f42fa4ad69c7 (patch)
tree8e92d0266bd71d5c92c2352e943f5b78ef19a097 /tools/util.py
parent129eae0265e3bd93c26c272d253ae9cbc6b88991 (diff)
Add benchmark for max latency (#1975)
Diffstat (limited to 'tools/util.py')
-rw-r--r--tools/util.py28
1 files changed, 24 insertions, 4 deletions
diff --git a/tools/util.py b/tools/util.py
index fc307512d..5576bef91 100644
--- a/tools/util.py
+++ b/tools/util.py
@@ -358,12 +358,32 @@ def extract_number(pattern, string):
return int(matches[0])
+def extract_max_latency_in_milliseconds(pattern, string):
+ matches = re.findall(pattern, string)
+ if len(matches) != 1:
+ return None
+ num = float(matches[0][0])
+ unit = matches[0][1]
+ if (unit == 'ms'):
+ return num
+ elif (unit == 'us'):
+ return num / 1000
+ elif (unit == 's'):
+ return num * 1000
+
+
def parse_wrk_output(output):
- req_per_sec = None
+ stats = {}
+ stats['req_per_sec'] = None
+ stats['max_latency'] = None
for line in output.split("\n"):
- if req_per_sec is None:
- req_per_sec = extract_number(r'Requests/sec:\s+(\d+)', line)
- return req_per_sec
+ if stats['req_per_sec'] is None:
+ stats['req_per_sec'] = extract_number(r'Requests/sec:\s+(\d+)',
+ line)
+ if stats['max_latency'] is None:
+ stats['max_latency'] = extract_max_latency_in_milliseconds(
+ r'Latency(?:\s+(\d+.\d+)([a-z]+)){3}', line)
+ return stats
def platform():