2022-08-05 12:55:59 +00:00
|
|
|
#!/usr/bin/env python3
|
2019-02-19 08:28:26 +00:00
|
|
|
|
[tools] Add an averaging script
This script averages numbers output from another script. It is useful
to average over a benchmark that outputs one or more results of the form
<key> <number> <unit>
key and unit are optional.
For example, if
$ bch --allow-natives-syntax toNumber.js
outputs
Number('undefined'): 155763 Kps
(+'undefined'): 193050 Kps
parseFloat('undefined'): 23736 Kps
then
$ avg.py 10 bch --allow-natives-syntax toNumber.js
will output
[10/10] (+'undefined') : avg 192,240.40 stddev 6,486.24 (185,529.00 - 206,186.00) Kps
[10/10] Number('undefined') : avg 156,990.10 stddev 16,327.56 (144,718.00 - 202,840.00) Kps
[10/10] parseFloat('undefined'): avg 22,885.80 stddev 1,941.80 ( 17,584.00 - 24,266.00) Kps
Change-Id: I237706da8ade1b152e04084e0189007460d359c5
Reviewed-on: https://chromium-review.googlesource.com/1128747
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54330}
2018-07-09 13:59:51 +00:00
|
|
|
# Copyright 2018 the V8 project authors. All rights reserved.
|
|
|
|
# Use of this source code is governed by a BSD-style license that can
|
|
|
|
# be found in the LICENSE file.
|
|
|
|
"""
|
|
|
|
This script averages numbers output from another script. It is useful
|
|
|
|
to average over a benchmark that outputs one or more results of the form
|
|
|
|
<key> <number> <unit>
|
|
|
|
key and unit are optional, but only one number per line is processed.
|
|
|
|
|
|
|
|
For example, if
|
|
|
|
$ bch --allow-natives-syntax toNumber.js
|
|
|
|
outputs
|
|
|
|
Number('undefined'): 155763
|
|
|
|
(+'undefined'): 193050 Kps
|
|
|
|
23736 Kps
|
|
|
|
then
|
|
|
|
$ avg.py 10 bch --allow-natives-syntax toNumber.js
|
|
|
|
will output
|
|
|
|
[10/10] (+'undefined') : avg 192,240.40 stddev 6,486.24 (185,529.00 - 206,186.00)
|
|
|
|
[10/10] Number('undefined') : avg 156,990.10 stddev 16,327.56 (144,718.00 - 202,840.00) Kps
|
|
|
|
[10/10] [default] : avg 22,885.80 stddev 1,941.80 ( 17,584.00 - 24,266.00) Kps
|
|
|
|
"""
|
|
|
|
|
2019-02-19 08:28:26 +00:00
|
|
|
# for py2/py3 compatibility
|
|
|
|
from __future__ import print_function
|
|
|
|
|
[tools] Add an averaging script
This script averages numbers output from another script. It is useful
to average over a benchmark that outputs one or more results of the form
<key> <number> <unit>
key and unit are optional.
For example, if
$ bch --allow-natives-syntax toNumber.js
outputs
Number('undefined'): 155763 Kps
(+'undefined'): 193050 Kps
parseFloat('undefined'): 23736 Kps
then
$ avg.py 10 bch --allow-natives-syntax toNumber.js
will output
[10/10] (+'undefined') : avg 192,240.40 stddev 6,486.24 (185,529.00 - 206,186.00) Kps
[10/10] Number('undefined') : avg 156,990.10 stddev 16,327.56 (144,718.00 - 202,840.00) Kps
[10/10] parseFloat('undefined'): avg 22,885.80 stddev 1,941.80 ( 17,584.00 - 24,266.00) Kps
Change-Id: I237706da8ade1b152e04084e0189007460d359c5
Reviewed-on: https://chromium-review.googlesource.com/1128747
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54330}
2018-07-09 13:59:51 +00:00
|
|
|
import argparse
|
2019-01-23 13:44:51 +00:00
|
|
|
import math
|
[tools] Add an averaging script
This script averages numbers output from another script. It is useful
to average over a benchmark that outputs one or more results of the form
<key> <number> <unit>
key and unit are optional.
For example, if
$ bch --allow-natives-syntax toNumber.js
outputs
Number('undefined'): 155763 Kps
(+'undefined'): 193050 Kps
parseFloat('undefined'): 23736 Kps
then
$ avg.py 10 bch --allow-natives-syntax toNumber.js
will output
[10/10] (+'undefined') : avg 192,240.40 stddev 6,486.24 (185,529.00 - 206,186.00) Kps
[10/10] Number('undefined') : avg 156,990.10 stddev 16,327.56 (144,718.00 - 202,840.00) Kps
[10/10] parseFloat('undefined'): avg 22,885.80 stddev 1,941.80 ( 17,584.00 - 24,266.00) Kps
Change-Id: I237706da8ade1b152e04084e0189007460d359c5
Reviewed-on: https://chromium-review.googlesource.com/1128747
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54330}
2018-07-09 13:59:51 +00:00
|
|
|
import re
|
|
|
|
import signal
|
2019-01-23 13:44:51 +00:00
|
|
|
import subprocess
|
|
|
|
import sys
|
[tools] Add an averaging script
This script averages numbers output from another script. It is useful
to average over a benchmark that outputs one or more results of the form
<key> <number> <unit>
key and unit are optional.
For example, if
$ bch --allow-natives-syntax toNumber.js
outputs
Number('undefined'): 155763 Kps
(+'undefined'): 193050 Kps
parseFloat('undefined'): 23736 Kps
then
$ avg.py 10 bch --allow-natives-syntax toNumber.js
will output
[10/10] (+'undefined') : avg 192,240.40 stddev 6,486.24 (185,529.00 - 206,186.00) Kps
[10/10] Number('undefined') : avg 156,990.10 stddev 16,327.56 (144,718.00 - 202,840.00) Kps
[10/10] parseFloat('undefined'): avg 22,885.80 stddev 1,941.80 ( 17,584.00 - 24,266.00) Kps
Change-Id: I237706da8ade1b152e04084e0189007460d359c5
Reviewed-on: https://chromium-review.googlesource.com/1128747
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54330}
2018-07-09 13:59:51 +00:00
|
|
|
|
2019-01-23 13:44:51 +00:00
|
|
|
PARSER = argparse.ArgumentParser(
|
[tools] Add an averaging script
This script averages numbers output from another script. It is useful
to average over a benchmark that outputs one or more results of the form
<key> <number> <unit>
key and unit are optional.
For example, if
$ bch --allow-natives-syntax toNumber.js
outputs
Number('undefined'): 155763 Kps
(+'undefined'): 193050 Kps
parseFloat('undefined'): 23736 Kps
then
$ avg.py 10 bch --allow-natives-syntax toNumber.js
will output
[10/10] (+'undefined') : avg 192,240.40 stddev 6,486.24 (185,529.00 - 206,186.00) Kps
[10/10] Number('undefined') : avg 156,990.10 stddev 16,327.56 (144,718.00 - 202,840.00) Kps
[10/10] parseFloat('undefined'): avg 22,885.80 stddev 1,941.80 ( 17,584.00 - 24,266.00) Kps
Change-Id: I237706da8ade1b152e04084e0189007460d359c5
Reviewed-on: https://chromium-review.googlesource.com/1128747
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54330}
2018-07-09 13:59:51 +00:00
|
|
|
description="A script that averages numbers from another script's output",
|
|
|
|
epilog="Example:\n\tavg.py 10 bash -c \"echo A: 100; echo B 120; sleep .1\""
|
|
|
|
)
|
2019-01-23 13:44:51 +00:00
|
|
|
PARSER.add_argument(
|
[tools] Add an averaging script
This script averages numbers output from another script. It is useful
to average over a benchmark that outputs one or more results of the form
<key> <number> <unit>
key and unit are optional.
For example, if
$ bch --allow-natives-syntax toNumber.js
outputs
Number('undefined'): 155763 Kps
(+'undefined'): 193050 Kps
parseFloat('undefined'): 23736 Kps
then
$ avg.py 10 bch --allow-natives-syntax toNumber.js
will output
[10/10] (+'undefined') : avg 192,240.40 stddev 6,486.24 (185,529.00 - 206,186.00) Kps
[10/10] Number('undefined') : avg 156,990.10 stddev 16,327.56 (144,718.00 - 202,840.00) Kps
[10/10] parseFloat('undefined'): avg 22,885.80 stddev 1,941.80 ( 17,584.00 - 24,266.00) Kps
Change-Id: I237706da8ade1b152e04084e0189007460d359c5
Reviewed-on: https://chromium-review.googlesource.com/1128747
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54330}
2018-07-09 13:59:51 +00:00
|
|
|
'repetitions',
|
|
|
|
type=int,
|
|
|
|
help="number of times the command should be repeated")
|
2019-01-23 13:44:51 +00:00
|
|
|
PARSER.add_argument(
|
[tools] Add an averaging script
This script averages numbers output from another script. It is useful
to average over a benchmark that outputs one or more results of the form
<key> <number> <unit>
key and unit are optional.
For example, if
$ bch --allow-natives-syntax toNumber.js
outputs
Number('undefined'): 155763 Kps
(+'undefined'): 193050 Kps
parseFloat('undefined'): 23736 Kps
then
$ avg.py 10 bch --allow-natives-syntax toNumber.js
will output
[10/10] (+'undefined') : avg 192,240.40 stddev 6,486.24 (185,529.00 - 206,186.00) Kps
[10/10] Number('undefined') : avg 156,990.10 stddev 16,327.56 (144,718.00 - 202,840.00) Kps
[10/10] parseFloat('undefined'): avg 22,885.80 stddev 1,941.80 ( 17,584.00 - 24,266.00) Kps
Change-Id: I237706da8ade1b152e04084e0189007460d359c5
Reviewed-on: https://chromium-review.googlesource.com/1128747
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54330}
2018-07-09 13:59:51 +00:00
|
|
|
'command',
|
|
|
|
nargs=argparse.REMAINDER,
|
|
|
|
help="command to run (no quotes needed)")
|
2019-01-23 13:44:51 +00:00
|
|
|
PARSER.add_argument(
|
[tools] Add an averaging script
This script averages numbers output from another script. It is useful
to average over a benchmark that outputs one or more results of the form
<key> <number> <unit>
key and unit are optional.
For example, if
$ bch --allow-natives-syntax toNumber.js
outputs
Number('undefined'): 155763 Kps
(+'undefined'): 193050 Kps
parseFloat('undefined'): 23736 Kps
then
$ avg.py 10 bch --allow-natives-syntax toNumber.js
will output
[10/10] (+'undefined') : avg 192,240.40 stddev 6,486.24 (185,529.00 - 206,186.00) Kps
[10/10] Number('undefined') : avg 156,990.10 stddev 16,327.56 (144,718.00 - 202,840.00) Kps
[10/10] parseFloat('undefined'): avg 22,885.80 stddev 1,941.80 ( 17,584.00 - 24,266.00) Kps
Change-Id: I237706da8ade1b152e04084e0189007460d359c5
Reviewed-on: https://chromium-review.googlesource.com/1128747
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54330}
2018-07-09 13:59:51 +00:00
|
|
|
'--echo',
|
|
|
|
'-e',
|
|
|
|
action='store_true',
|
|
|
|
default=False,
|
|
|
|
help="set this flag to echo the command's output")
|
|
|
|
|
2019-01-23 13:44:51 +00:00
|
|
|
ARGS = vars(PARSER.parse_args())
|
[tools] Add an averaging script
This script averages numbers output from another script. It is useful
to average over a benchmark that outputs one or more results of the form
<key> <number> <unit>
key and unit are optional.
For example, if
$ bch --allow-natives-syntax toNumber.js
outputs
Number('undefined'): 155763 Kps
(+'undefined'): 193050 Kps
parseFloat('undefined'): 23736 Kps
then
$ avg.py 10 bch --allow-natives-syntax toNumber.js
will output
[10/10] (+'undefined') : avg 192,240.40 stddev 6,486.24 (185,529.00 - 206,186.00) Kps
[10/10] Number('undefined') : avg 156,990.10 stddev 16,327.56 (144,718.00 - 202,840.00) Kps
[10/10] parseFloat('undefined'): avg 22,885.80 stddev 1,941.80 ( 17,584.00 - 24,266.00) Kps
Change-Id: I237706da8ade1b152e04084e0189007460d359c5
Reviewed-on: https://chromium-review.googlesource.com/1128747
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54330}
2018-07-09 13:59:51 +00:00
|
|
|
|
2019-01-23 13:44:51 +00:00
|
|
|
if not ARGS['command']:
|
[tools] Add an averaging script
This script averages numbers output from another script. It is useful
to average over a benchmark that outputs one or more results of the form
<key> <number> <unit>
key and unit are optional.
For example, if
$ bch --allow-natives-syntax toNumber.js
outputs
Number('undefined'): 155763 Kps
(+'undefined'): 193050 Kps
parseFloat('undefined'): 23736 Kps
then
$ avg.py 10 bch --allow-natives-syntax toNumber.js
will output
[10/10] (+'undefined') : avg 192,240.40 stddev 6,486.24 (185,529.00 - 206,186.00) Kps
[10/10] Number('undefined') : avg 156,990.10 stddev 16,327.56 (144,718.00 - 202,840.00) Kps
[10/10] parseFloat('undefined'): avg 22,885.80 stddev 1,941.80 ( 17,584.00 - 24,266.00) Kps
Change-Id: I237706da8ade1b152e04084e0189007460d359c5
Reviewed-on: https://chromium-review.googlesource.com/1128747
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54330}
2018-07-09 13:59:51 +00:00
|
|
|
print("No command provided.")
|
|
|
|
exit(1)
|
|
|
|
|
|
|
|
|
|
|
|
class FieldWidth:
|
|
|
|
|
2019-01-23 13:44:51 +00:00
|
|
|
def __init__(self, points=0, key=0, average=0, stddev=0, min_width=0, max_width=0):
|
|
|
|
self.widths = dict(points=points, key=key, average=average, stddev=stddev,
|
|
|
|
min=min_width, max=max_width)
|
[tools] Add an averaging script
This script averages numbers output from another script. It is useful
to average over a benchmark that outputs one or more results of the form
<key> <number> <unit>
key and unit are optional.
For example, if
$ bch --allow-natives-syntax toNumber.js
outputs
Number('undefined'): 155763 Kps
(+'undefined'): 193050 Kps
parseFloat('undefined'): 23736 Kps
then
$ avg.py 10 bch --allow-natives-syntax toNumber.js
will output
[10/10] (+'undefined') : avg 192,240.40 stddev 6,486.24 (185,529.00 - 206,186.00) Kps
[10/10] Number('undefined') : avg 156,990.10 stddev 16,327.56 (144,718.00 - 202,840.00) Kps
[10/10] parseFloat('undefined'): avg 22,885.80 stddev 1,941.80 ( 17,584.00 - 24,266.00) Kps
Change-Id: I237706da8ade1b152e04084e0189007460d359c5
Reviewed-on: https://chromium-review.googlesource.com/1128747
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54330}
2018-07-09 13:59:51 +00:00
|
|
|
|
2019-01-23 13:44:51 +00:00
|
|
|
def max_widths(self, other):
|
|
|
|
self.widths = {k: max(v, other.widths[k]) for k, v in self.widths.items()}
|
[tools] Add an averaging script
This script averages numbers output from another script. It is useful
to average over a benchmark that outputs one or more results of the form
<key> <number> <unit>
key and unit are optional.
For example, if
$ bch --allow-natives-syntax toNumber.js
outputs
Number('undefined'): 155763 Kps
(+'undefined'): 193050 Kps
parseFloat('undefined'): 23736 Kps
then
$ avg.py 10 bch --allow-natives-syntax toNumber.js
will output
[10/10] (+'undefined') : avg 192,240.40 stddev 6,486.24 (185,529.00 - 206,186.00) Kps
[10/10] Number('undefined') : avg 156,990.10 stddev 16,327.56 (144,718.00 - 202,840.00) Kps
[10/10] parseFloat('undefined'): avg 22,885.80 stddev 1,941.80 ( 17,584.00 - 24,266.00) Kps
Change-Id: I237706da8ade1b152e04084e0189007460d359c5
Reviewed-on: https://chromium-review.googlesource.com/1128747
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54330}
2018-07-09 13:59:51 +00:00
|
|
|
|
|
|
|
def __getattr__(self, key):
|
2019-01-23 13:44:51 +00:00
|
|
|
return self.widths[key]
|
[tools] Add an averaging script
This script averages numbers output from another script. It is useful
to average over a benchmark that outputs one or more results of the form
<key> <number> <unit>
key and unit are optional.
For example, if
$ bch --allow-natives-syntax toNumber.js
outputs
Number('undefined'): 155763 Kps
(+'undefined'): 193050 Kps
parseFloat('undefined'): 23736 Kps
then
$ avg.py 10 bch --allow-natives-syntax toNumber.js
will output
[10/10] (+'undefined') : avg 192,240.40 stddev 6,486.24 (185,529.00 - 206,186.00) Kps
[10/10] Number('undefined') : avg 156,990.10 stddev 16,327.56 (144,718.00 - 202,840.00) Kps
[10/10] parseFloat('undefined'): avg 22,885.80 stddev 1,941.80 ( 17,584.00 - 24,266.00) Kps
Change-Id: I237706da8ade1b152e04084e0189007460d359c5
Reviewed-on: https://chromium-review.googlesource.com/1128747
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54330}
2018-07-09 13:59:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
def fmtS(string, width=0):
|
|
|
|
return "{0:<{1}}".format(string, width)
|
|
|
|
|
|
|
|
|
|
|
|
def fmtN(num, width=0):
|
|
|
|
return "{0:>{1},.2f}".format(num, width)
|
|
|
|
|
|
|
|
|
2019-01-23 13:44:51 +00:00
|
|
|
def fmt(num):
|
|
|
|
return "{0:>,.2f}".format(num)
|
|
|
|
|
|
|
|
|
|
|
|
def format_line(points, key, average, stddev, min_value, max_value,
|
|
|
|
unit_string, widths):
|
|
|
|
return "{:>{}}; {:<{}}; {:>{}}; {:>{}}; {:>{}}; {:>{}}; {}".format(
|
|
|
|
points, widths.points,
|
|
|
|
key, widths.key,
|
|
|
|
average, widths.average,
|
|
|
|
stddev, widths.stddev,
|
|
|
|
min_value, widths.min,
|
|
|
|
max_value, widths.max,
|
|
|
|
unit_string)
|
|
|
|
|
|
|
|
|
|
|
|
def fmt_reps(msrmnt):
|
|
|
|
rep_string = str(ARGS['repetitions'])
|
|
|
|
return "[{0:>{1}}/{2}]".format(msrmnt.size(), len(rep_string), rep_string)
|
|
|
|
|
|
|
|
|
[tools] Add an averaging script
This script averages numbers output from another script. It is useful
to average over a benchmark that outputs one or more results of the form
<key> <number> <unit>
key and unit are optional.
For example, if
$ bch --allow-natives-syntax toNumber.js
outputs
Number('undefined'): 155763 Kps
(+'undefined'): 193050 Kps
parseFloat('undefined'): 23736 Kps
then
$ avg.py 10 bch --allow-natives-syntax toNumber.js
will output
[10/10] (+'undefined') : avg 192,240.40 stddev 6,486.24 (185,529.00 - 206,186.00) Kps
[10/10] Number('undefined') : avg 156,990.10 stddev 16,327.56 (144,718.00 - 202,840.00) Kps
[10/10] parseFloat('undefined'): avg 22,885.80 stddev 1,941.80 ( 17,584.00 - 24,266.00) Kps
Change-Id: I237706da8ade1b152e04084e0189007460d359c5
Reviewed-on: https://chromium-review.googlesource.com/1128747
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54330}
2018-07-09 13:59:51 +00:00
|
|
|
class Measurement:
|
|
|
|
|
|
|
|
def __init__(self, key, unit):
|
|
|
|
self.key = key
|
|
|
|
self.unit = unit
|
|
|
|
self.values = []
|
|
|
|
self.average = 0
|
|
|
|
self.count = 0
|
|
|
|
self.M2 = 0
|
|
|
|
self.min = float("inf")
|
|
|
|
self.max = -float("inf")
|
|
|
|
|
|
|
|
def addValue(self, value):
|
|
|
|
try:
|
|
|
|
num_value = float(value)
|
|
|
|
self.values.append(num_value)
|
|
|
|
self.min = min(self.min, num_value)
|
|
|
|
self.max = max(self.max, num_value)
|
|
|
|
self.count = self.count + 1
|
|
|
|
delta = num_value - self.average
|
|
|
|
self.average = self.average + delta / self.count
|
|
|
|
delta2 = num_value - self.average
|
|
|
|
self.M2 = self.M2 + delta * delta2
|
|
|
|
except ValueError:
|
|
|
|
print("Ignoring non-numeric value", value)
|
|
|
|
|
2019-01-23 13:44:51 +00:00
|
|
|
def status(self, widths):
|
|
|
|
return "{} {}: avg {} stddev {} ({} - {}) {}".format(
|
|
|
|
fmt_reps(self),
|
|
|
|
fmtS(self.key, widths.key), fmtN(self.average, widths.average),
|
|
|
|
fmtN(self.stddev(), widths.stddev), fmtN(self.min, widths.min),
|
|
|
|
fmtN(self.max, widths.max), fmtS(self.unit_string()))
|
|
|
|
|
|
|
|
def result(self, widths):
|
|
|
|
return format_line(self.size(), self.key, fmt(self.average),
|
|
|
|
fmt(self.stddev()), fmt(self.min),
|
|
|
|
fmt(self.max), self.unit_string(),
|
|
|
|
widths)
|
[tools] Add an averaging script
This script averages numbers output from another script. It is useful
to average over a benchmark that outputs one or more results of the form
<key> <number> <unit>
key and unit are optional.
For example, if
$ bch --allow-natives-syntax toNumber.js
outputs
Number('undefined'): 155763 Kps
(+'undefined'): 193050 Kps
parseFloat('undefined'): 23736 Kps
then
$ avg.py 10 bch --allow-natives-syntax toNumber.js
will output
[10/10] (+'undefined') : avg 192,240.40 stddev 6,486.24 (185,529.00 - 206,186.00) Kps
[10/10] Number('undefined') : avg 156,990.10 stddev 16,327.56 (144,718.00 - 202,840.00) Kps
[10/10] parseFloat('undefined'): avg 22,885.80 stddev 1,941.80 ( 17,584.00 - 24,266.00) Kps
Change-Id: I237706da8ade1b152e04084e0189007460d359c5
Reviewed-on: https://chromium-review.googlesource.com/1128747
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54330}
2018-07-09 13:59:51 +00:00
|
|
|
|
|
|
|
def unit_string(self):
|
2019-01-23 13:44:51 +00:00
|
|
|
if not self.unit:
|
[tools] Add an averaging script
This script averages numbers output from another script. It is useful
to average over a benchmark that outputs one or more results of the form
<key> <number> <unit>
key and unit are optional.
For example, if
$ bch --allow-natives-syntax toNumber.js
outputs
Number('undefined'): 155763 Kps
(+'undefined'): 193050 Kps
parseFloat('undefined'): 23736 Kps
then
$ avg.py 10 bch --allow-natives-syntax toNumber.js
will output
[10/10] (+'undefined') : avg 192,240.40 stddev 6,486.24 (185,529.00 - 206,186.00) Kps
[10/10] Number('undefined') : avg 156,990.10 stddev 16,327.56 (144,718.00 - 202,840.00) Kps
[10/10] parseFloat('undefined'): avg 22,885.80 stddev 1,941.80 ( 17,584.00 - 24,266.00) Kps
Change-Id: I237706da8ade1b152e04084e0189007460d359c5
Reviewed-on: https://chromium-review.googlesource.com/1128747
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54330}
2018-07-09 13:59:51 +00:00
|
|
|
return ""
|
|
|
|
return self.unit
|
|
|
|
|
|
|
|
def variance(self):
|
|
|
|
if self.count < 2:
|
|
|
|
return float('NaN')
|
|
|
|
return self.M2 / (self.count - 1)
|
|
|
|
|
|
|
|
def stddev(self):
|
2019-01-23 13:44:51 +00:00
|
|
|
return math.sqrt(self.variance())
|
[tools] Add an averaging script
This script averages numbers output from another script. It is useful
to average over a benchmark that outputs one or more results of the form
<key> <number> <unit>
key and unit are optional.
For example, if
$ bch --allow-natives-syntax toNumber.js
outputs
Number('undefined'): 155763 Kps
(+'undefined'): 193050 Kps
parseFloat('undefined'): 23736 Kps
then
$ avg.py 10 bch --allow-natives-syntax toNumber.js
will output
[10/10] (+'undefined') : avg 192,240.40 stddev 6,486.24 (185,529.00 - 206,186.00) Kps
[10/10] Number('undefined') : avg 156,990.10 stddev 16,327.56 (144,718.00 - 202,840.00) Kps
[10/10] parseFloat('undefined'): avg 22,885.80 stddev 1,941.80 ( 17,584.00 - 24,266.00) Kps
Change-Id: I237706da8ade1b152e04084e0189007460d359c5
Reviewed-on: https://chromium-review.googlesource.com/1128747
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54330}
2018-07-09 13:59:51 +00:00
|
|
|
|
|
|
|
def size(self):
|
|
|
|
return len(self.values)
|
|
|
|
|
|
|
|
def widths(self):
|
|
|
|
return FieldWidth(
|
2019-01-23 13:44:51 +00:00
|
|
|
points=len("{}".format(self.size())) + 2,
|
|
|
|
key=len(self.key),
|
|
|
|
average=len(fmt(self.average)),
|
|
|
|
stddev=len(fmt(self.stddev())),
|
|
|
|
min_width=len(fmt(self.min)),
|
|
|
|
max_width=len(fmt(self.max)))
|
[tools] Add an averaging script
This script averages numbers output from another script. It is useful
to average over a benchmark that outputs one or more results of the form
<key> <number> <unit>
key and unit are optional.
For example, if
$ bch --allow-natives-syntax toNumber.js
outputs
Number('undefined'): 155763 Kps
(+'undefined'): 193050 Kps
parseFloat('undefined'): 23736 Kps
then
$ avg.py 10 bch --allow-natives-syntax toNumber.js
will output
[10/10] (+'undefined') : avg 192,240.40 stddev 6,486.24 (185,529.00 - 206,186.00) Kps
[10/10] Number('undefined') : avg 156,990.10 stddev 16,327.56 (144,718.00 - 202,840.00) Kps
[10/10] parseFloat('undefined'): avg 22,885.80 stddev 1,941.80 ( 17,584.00 - 24,266.00) Kps
Change-Id: I237706da8ade1b152e04084e0189007460d359c5
Reviewed-on: https://chromium-review.googlesource.com/1128747
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54330}
2018-07-09 13:59:51 +00:00
|
|
|
|
|
|
|
|
2019-01-23 13:44:51 +00:00
|
|
|
def result_header(widths):
|
|
|
|
return format_line("#/{}".format(ARGS['repetitions']),
|
|
|
|
"id", "avg", "stddev", "min", "max", "unit", widths)
|
[tools] Add an averaging script
This script averages numbers output from another script. It is useful
to average over a benchmark that outputs one or more results of the form
<key> <number> <unit>
key and unit are optional.
For example, if
$ bch --allow-natives-syntax toNumber.js
outputs
Number('undefined'): 155763 Kps
(+'undefined'): 193050 Kps
parseFloat('undefined'): 23736 Kps
then
$ avg.py 10 bch --allow-natives-syntax toNumber.js
will output
[10/10] (+'undefined') : avg 192,240.40 stddev 6,486.24 (185,529.00 - 206,186.00) Kps
[10/10] Number('undefined') : avg 156,990.10 stddev 16,327.56 (144,718.00 - 202,840.00) Kps
[10/10] parseFloat('undefined'): avg 22,885.80 stddev 1,941.80 ( 17,584.00 - 24,266.00) Kps
Change-Id: I237706da8ade1b152e04084e0189007460d359c5
Reviewed-on: https://chromium-review.googlesource.com/1128747
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54330}
2018-07-09 13:59:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
class Measurements:
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
self.all = {}
|
|
|
|
self.default_key = '[default]'
|
2019-01-23 13:44:51 +00:00
|
|
|
self.max_widths = FieldWidth(
|
|
|
|
points=len("{}".format(ARGS['repetitions'])) + 2,
|
|
|
|
key=len("id"),
|
|
|
|
average=len("avg"),
|
|
|
|
stddev=len("stddev"),
|
|
|
|
min_width=len("min"),
|
|
|
|
max_width=len("max"))
|
|
|
|
self.last_status_len = 0
|
[tools] Add an averaging script
This script averages numbers output from another script. It is useful
to average over a benchmark that outputs one or more results of the form
<key> <number> <unit>
key and unit are optional.
For example, if
$ bch --allow-natives-syntax toNumber.js
outputs
Number('undefined'): 155763 Kps
(+'undefined'): 193050 Kps
parseFloat('undefined'): 23736 Kps
then
$ avg.py 10 bch --allow-natives-syntax toNumber.js
will output
[10/10] (+'undefined') : avg 192,240.40 stddev 6,486.24 (185,529.00 - 206,186.00) Kps
[10/10] Number('undefined') : avg 156,990.10 stddev 16,327.56 (144,718.00 - 202,840.00) Kps
[10/10] parseFloat('undefined'): avg 22,885.80 stddev 1,941.80 ( 17,584.00 - 24,266.00) Kps
Change-Id: I237706da8ade1b152e04084e0189007460d359c5
Reviewed-on: https://chromium-review.googlesource.com/1128747
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54330}
2018-07-09 13:59:51 +00:00
|
|
|
|
|
|
|
def record(self, key, value, unit):
|
2019-01-23 13:44:51 +00:00
|
|
|
if not key:
|
[tools] Add an averaging script
This script averages numbers output from another script. It is useful
to average over a benchmark that outputs one or more results of the form
<key> <number> <unit>
key and unit are optional.
For example, if
$ bch --allow-natives-syntax toNumber.js
outputs
Number('undefined'): 155763 Kps
(+'undefined'): 193050 Kps
parseFloat('undefined'): 23736 Kps
then
$ avg.py 10 bch --allow-natives-syntax toNumber.js
will output
[10/10] (+'undefined') : avg 192,240.40 stddev 6,486.24 (185,529.00 - 206,186.00) Kps
[10/10] Number('undefined') : avg 156,990.10 stddev 16,327.56 (144,718.00 - 202,840.00) Kps
[10/10] parseFloat('undefined'): avg 22,885.80 stddev 1,941.80 ( 17,584.00 - 24,266.00) Kps
Change-Id: I237706da8ade1b152e04084e0189007460d359c5
Reviewed-on: https://chromium-review.googlesource.com/1128747
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54330}
2018-07-09 13:59:51 +00:00
|
|
|
key = self.default_key
|
|
|
|
if key not in self.all:
|
|
|
|
self.all[key] = Measurement(key, unit)
|
|
|
|
self.all[key].addValue(value)
|
2019-01-23 13:44:51 +00:00
|
|
|
self.max_widths.max_widths(self.all[key].widths())
|
[tools] Add an averaging script
This script averages numbers output from another script. It is useful
to average over a benchmark that outputs one or more results of the form
<key> <number> <unit>
key and unit are optional.
For example, if
$ bch --allow-natives-syntax toNumber.js
outputs
Number('undefined'): 155763 Kps
(+'undefined'): 193050 Kps
parseFloat('undefined'): 23736 Kps
then
$ avg.py 10 bch --allow-natives-syntax toNumber.js
will output
[10/10] (+'undefined') : avg 192,240.40 stddev 6,486.24 (185,529.00 - 206,186.00) Kps
[10/10] Number('undefined') : avg 156,990.10 stddev 16,327.56 (144,718.00 - 202,840.00) Kps
[10/10] parseFloat('undefined'): avg 22,885.80 stddev 1,941.80 ( 17,584.00 - 24,266.00) Kps
Change-Id: I237706da8ade1b152e04084e0189007460d359c5
Reviewed-on: https://chromium-review.googlesource.com/1128747
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54330}
2018-07-09 13:59:51 +00:00
|
|
|
|
|
|
|
def any(self):
|
2019-01-23 13:44:51 +00:00
|
|
|
if self.all:
|
[tools] Add an averaging script
This script averages numbers output from another script. It is useful
to average over a benchmark that outputs one or more results of the form
<key> <number> <unit>
key and unit are optional.
For example, if
$ bch --allow-natives-syntax toNumber.js
outputs
Number('undefined'): 155763 Kps
(+'undefined'): 193050 Kps
parseFloat('undefined'): 23736 Kps
then
$ avg.py 10 bch --allow-natives-syntax toNumber.js
will output
[10/10] (+'undefined') : avg 192,240.40 stddev 6,486.24 (185,529.00 - 206,186.00) Kps
[10/10] Number('undefined') : avg 156,990.10 stddev 16,327.56 (144,718.00 - 202,840.00) Kps
[10/10] parseFloat('undefined'): avg 22,885.80 stddev 1,941.80 ( 17,584.00 - 24,266.00) Kps
Change-Id: I237706da8ade1b152e04084e0189007460d359c5
Reviewed-on: https://chromium-review.googlesource.com/1128747
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54330}
2018-07-09 13:59:51 +00:00
|
|
|
return next(iter(self.all.values()))
|
2019-01-23 13:44:51 +00:00
|
|
|
return None
|
[tools] Add an averaging script
This script averages numbers output from another script. It is useful
to average over a benchmark that outputs one or more results of the form
<key> <number> <unit>
key and unit are optional.
For example, if
$ bch --allow-natives-syntax toNumber.js
outputs
Number('undefined'): 155763 Kps
(+'undefined'): 193050 Kps
parseFloat('undefined'): 23736 Kps
then
$ avg.py 10 bch --allow-natives-syntax toNumber.js
will output
[10/10] (+'undefined') : avg 192,240.40 stddev 6,486.24 (185,529.00 - 206,186.00) Kps
[10/10] Number('undefined') : avg 156,990.10 stddev 16,327.56 (144,718.00 - 202,840.00) Kps
[10/10] parseFloat('undefined'): avg 22,885.80 stddev 1,941.80 ( 17,584.00 - 24,266.00) Kps
Change-Id: I237706da8ade1b152e04084e0189007460d359c5
Reviewed-on: https://chromium-review.googlesource.com/1128747
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54330}
2018-07-09 13:59:51 +00:00
|
|
|
|
2019-01-23 13:44:51 +00:00
|
|
|
def print_results(self):
|
|
|
|
print("{:<{}}".format("", self.last_status_len), end="\r")
|
|
|
|
print(result_header(self.max_widths), sep=" ")
|
|
|
|
for key in sorted(self.all):
|
|
|
|
print(self.all[key].result(self.max_widths), sep=" ")
|
[tools] Add an averaging script
This script averages numbers output from another script. It is useful
to average over a benchmark that outputs one or more results of the form
<key> <number> <unit>
key and unit are optional.
For example, if
$ bch --allow-natives-syntax toNumber.js
outputs
Number('undefined'): 155763 Kps
(+'undefined'): 193050 Kps
parseFloat('undefined'): 23736 Kps
then
$ avg.py 10 bch --allow-natives-syntax toNumber.js
will output
[10/10] (+'undefined') : avg 192,240.40 stddev 6,486.24 (185,529.00 - 206,186.00) Kps
[10/10] Number('undefined') : avg 156,990.10 stddev 16,327.56 (144,718.00 - 202,840.00) Kps
[10/10] parseFloat('undefined'): avg 22,885.80 stddev 1,941.80 ( 17,584.00 - 24,266.00) Kps
Change-Id: I237706da8ade1b152e04084e0189007460d359c5
Reviewed-on: https://chromium-review.googlesource.com/1128747
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54330}
2018-07-09 13:59:51 +00:00
|
|
|
|
|
|
|
def print_status(self):
|
2019-01-23 13:44:51 +00:00
|
|
|
status = "No results found. Check format?"
|
|
|
|
measurement = MEASUREMENTS.any()
|
|
|
|
if measurement:
|
|
|
|
status = measurement.status(MEASUREMENTS.max_widths)
|
|
|
|
print("{:<{}}".format(status, self.last_status_len), end="\r")
|
|
|
|
self.last_status_len = len(status)
|
[tools] Add an averaging script
This script averages numbers output from another script. It is useful
to average over a benchmark that outputs one or more results of the form
<key> <number> <unit>
key and unit are optional.
For example, if
$ bch --allow-natives-syntax toNumber.js
outputs
Number('undefined'): 155763 Kps
(+'undefined'): 193050 Kps
parseFloat('undefined'): 23736 Kps
then
$ avg.py 10 bch --allow-natives-syntax toNumber.js
will output
[10/10] (+'undefined') : avg 192,240.40 stddev 6,486.24 (185,529.00 - 206,186.00) Kps
[10/10] Number('undefined') : avg 156,990.10 stddev 16,327.56 (144,718.00 - 202,840.00) Kps
[10/10] parseFloat('undefined'): avg 22,885.80 stddev 1,941.80 ( 17,584.00 - 24,266.00) Kps
Change-Id: I237706da8ade1b152e04084e0189007460d359c5
Reviewed-on: https://chromium-review.googlesource.com/1128747
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54330}
2018-07-09 13:59:51 +00:00
|
|
|
|
|
|
|
|
2019-01-23 13:44:51 +00:00
|
|
|
MEASUREMENTS = Measurements()
|
[tools] Add an averaging script
This script averages numbers output from another script. It is useful
to average over a benchmark that outputs one or more results of the form
<key> <number> <unit>
key and unit are optional.
For example, if
$ bch --allow-natives-syntax toNumber.js
outputs
Number('undefined'): 155763 Kps
(+'undefined'): 193050 Kps
parseFloat('undefined'): 23736 Kps
then
$ avg.py 10 bch --allow-natives-syntax toNumber.js
will output
[10/10] (+'undefined') : avg 192,240.40 stddev 6,486.24 (185,529.00 - 206,186.00) Kps
[10/10] Number('undefined') : avg 156,990.10 stddev 16,327.56 (144,718.00 - 202,840.00) Kps
[10/10] parseFloat('undefined'): avg 22,885.80 stddev 1,941.80 ( 17,584.00 - 24,266.00) Kps
Change-Id: I237706da8ade1b152e04084e0189007460d359c5
Reviewed-on: https://chromium-review.googlesource.com/1128747
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54330}
2018-07-09 13:59:51 +00:00
|
|
|
|
|
|
|
|
2019-01-23 13:44:51 +00:00
|
|
|
def signal_handler(signum, frame):
|
[tools] Add an averaging script
This script averages numbers output from another script. It is useful
to average over a benchmark that outputs one or more results of the form
<key> <number> <unit>
key and unit are optional.
For example, if
$ bch --allow-natives-syntax toNumber.js
outputs
Number('undefined'): 155763 Kps
(+'undefined'): 193050 Kps
parseFloat('undefined'): 23736 Kps
then
$ avg.py 10 bch --allow-natives-syntax toNumber.js
will output
[10/10] (+'undefined') : avg 192,240.40 stddev 6,486.24 (185,529.00 - 206,186.00) Kps
[10/10] Number('undefined') : avg 156,990.10 stddev 16,327.56 (144,718.00 - 202,840.00) Kps
[10/10] parseFloat('undefined'): avg 22,885.80 stddev 1,941.80 ( 17,584.00 - 24,266.00) Kps
Change-Id: I237706da8ade1b152e04084e0189007460d359c5
Reviewed-on: https://chromium-review.googlesource.com/1128747
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54330}
2018-07-09 13:59:51 +00:00
|
|
|
print("", end="\r")
|
2019-01-23 13:44:51 +00:00
|
|
|
MEASUREMENTS.print_results()
|
[tools] Add an averaging script
This script averages numbers output from another script. It is useful
to average over a benchmark that outputs one or more results of the form
<key> <number> <unit>
key and unit are optional.
For example, if
$ bch --allow-natives-syntax toNumber.js
outputs
Number('undefined'): 155763 Kps
(+'undefined'): 193050 Kps
parseFloat('undefined'): 23736 Kps
then
$ avg.py 10 bch --allow-natives-syntax toNumber.js
will output
[10/10] (+'undefined') : avg 192,240.40 stddev 6,486.24 (185,529.00 - 206,186.00) Kps
[10/10] Number('undefined') : avg 156,990.10 stddev 16,327.56 (144,718.00 - 202,840.00) Kps
[10/10] parseFloat('undefined'): avg 22,885.80 stddev 1,941.80 ( 17,584.00 - 24,266.00) Kps
Change-Id: I237706da8ade1b152e04084e0189007460d359c5
Reviewed-on: https://chromium-review.googlesource.com/1128747
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54330}
2018-07-09 13:59:51 +00:00
|
|
|
sys.exit(0)
|
|
|
|
|
|
|
|
|
|
|
|
signal.signal(signal.SIGINT, signal_handler)
|
|
|
|
|
2019-01-23 13:44:51 +00:00
|
|
|
SCORE_REGEX = (r'\A((console.timeEnd: )?'
|
|
|
|
r'(?P<key>[^\s:,]+)[,:]?)?'
|
|
|
|
r'(^\s*|\s+)'
|
|
|
|
r'(?P<value>[0-9]+(.[0-9]+)?)'
|
|
|
|
r'\ ?(?P<unit>[^\d\W]\w*)?[.\s]*\Z')
|
|
|
|
|
|
|
|
for x in range(0, ARGS['repetitions']):
|
|
|
|
proc = subprocess.Popen(ARGS['command'], stdout=subprocess.PIPE)
|
[tools] Add an averaging script
This script averages numbers output from another script. It is useful
to average over a benchmark that outputs one or more results of the form
<key> <number> <unit>
key and unit are optional.
For example, if
$ bch --allow-natives-syntax toNumber.js
outputs
Number('undefined'): 155763 Kps
(+'undefined'): 193050 Kps
parseFloat('undefined'): 23736 Kps
then
$ avg.py 10 bch --allow-natives-syntax toNumber.js
will output
[10/10] (+'undefined') : avg 192,240.40 stddev 6,486.24 (185,529.00 - 206,186.00) Kps
[10/10] Number('undefined') : avg 156,990.10 stddev 16,327.56 (144,718.00 - 202,840.00) Kps
[10/10] parseFloat('undefined'): avg 22,885.80 stddev 1,941.80 ( 17,584.00 - 24,266.00) Kps
Change-Id: I237706da8ade1b152e04084e0189007460d359c5
Reviewed-on: https://chromium-review.googlesource.com/1128747
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54330}
2018-07-09 13:59:51 +00:00
|
|
|
for line in proc.stdout:
|
2019-01-23 13:44:51 +00:00
|
|
|
if ARGS['echo']:
|
[tools] Add an averaging script
This script averages numbers output from another script. It is useful
to average over a benchmark that outputs one or more results of the form
<key> <number> <unit>
key and unit are optional.
For example, if
$ bch --allow-natives-syntax toNumber.js
outputs
Number('undefined'): 155763 Kps
(+'undefined'): 193050 Kps
parseFloat('undefined'): 23736 Kps
then
$ avg.py 10 bch --allow-natives-syntax toNumber.js
will output
[10/10] (+'undefined') : avg 192,240.40 stddev 6,486.24 (185,529.00 - 206,186.00) Kps
[10/10] Number('undefined') : avg 156,990.10 stddev 16,327.56 (144,718.00 - 202,840.00) Kps
[10/10] parseFloat('undefined'): avg 22,885.80 stddev 1,941.80 ( 17,584.00 - 24,266.00) Kps
Change-Id: I237706da8ade1b152e04084e0189007460d359c5
Reviewed-on: https://chromium-review.googlesource.com/1128747
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54330}
2018-07-09 13:59:51 +00:00
|
|
|
print(line.decode(), end="")
|
2019-01-23 13:44:51 +00:00
|
|
|
for m in re.finditer(SCORE_REGEX, line.decode()):
|
|
|
|
MEASUREMENTS.record(m.group('key'), m.group('value'), m.group('unit'))
|
[tools] Add an averaging script
This script averages numbers output from another script. It is useful
to average over a benchmark that outputs one or more results of the form
<key> <number> <unit>
key and unit are optional.
For example, if
$ bch --allow-natives-syntax toNumber.js
outputs
Number('undefined'): 155763 Kps
(+'undefined'): 193050 Kps
parseFloat('undefined'): 23736 Kps
then
$ avg.py 10 bch --allow-natives-syntax toNumber.js
will output
[10/10] (+'undefined') : avg 192,240.40 stddev 6,486.24 (185,529.00 - 206,186.00) Kps
[10/10] Number('undefined') : avg 156,990.10 stddev 16,327.56 (144,718.00 - 202,840.00) Kps
[10/10] parseFloat('undefined'): avg 22,885.80 stddev 1,941.80 ( 17,584.00 - 24,266.00) Kps
Change-Id: I237706da8ade1b152e04084e0189007460d359c5
Reviewed-on: https://chromium-review.googlesource.com/1128747
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54330}
2018-07-09 13:59:51 +00:00
|
|
|
proc.wait()
|
|
|
|
if proc.returncode != 0:
|
|
|
|
print("Child exited with status %d" % proc.returncode)
|
|
|
|
break
|
|
|
|
|
2019-01-23 13:44:51 +00:00
|
|
|
MEASUREMENTS.print_status()
|
|
|
|
|
|
|
|
# Print final results
|
|
|
|
MEASUREMENTS.print_results()
|