mirror of
https://github.com/denoland/deno.git
synced 2025-09-27 20:59:10 +00:00
Add benchmark for max latency (#1975)
This commit is contained in:
parent
129eae0265
commit
3cc90d9bcf
8 changed files with 90 additions and 19 deletions
|
@ -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():
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue