[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v6 13/15] scripts/simplebench: improve view of ascii table
From: |
Vladimir Sementsov-Ogievskiy |
Subject: |
[PATCH v6 13/15] scripts/simplebench: improve view of ascii table |
Date: |
Fri, 18 Sep 2020 21:19:49 +0300 |
Introduce dynamic float precision and use percentage to show delta.
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
scripts/simplebench/simplebench.py | 26 +++++++++++++++++++++++++-
1 file changed, 25 insertions(+), 1 deletion(-)
diff --git a/scripts/simplebench/simplebench.py
b/scripts/simplebench/simplebench.py
index 716d7fe9b2..56d3a91ea2 100644
--- a/scripts/simplebench/simplebench.py
+++ b/scripts/simplebench/simplebench.py
@@ -79,10 +79,34 @@ def bench_one(test_func, test_env, test_case, count=5,
initial_run=True):
return result
+def format_float(x):
+ res = round(x)
+ if res >= 100:
+ return str(res)
+
+ res = f'{x:.1f}'
+ if len(res) >= 4:
+ return res
+
+ return f'{x:.2f}'
+
+
+def format_percent(x):
+ x *= 100
+
+ res = round(x)
+ if res >= 10:
+ return str(res)
+
+ return f'{x:.1f}' if res >= 1 else f'{x:.2f}'
+
+
def ascii_one(result):
"""Return ASCII representation of bench_one() returned dict."""
if 'average' in result:
- s = '{:.2f} +- {:.2f}'.format(result['average'], result['delta'])
+ avg = result['average']
+ delta_pr = result['delta'] / avg
+ s = f'{format_float(avg)}±{format_percent(delta_pr)}%'
if 'n-failed' in result:
s += '\n({} failed)'.format(result['n-failed'])
return s
--
2.21.3
- Re: [PATCH v6 08/15] block: introduce preallocate filter, (continued)
[PATCH v6 10/15] iotests: qemu_io_silent: support --image-opts, Vladimir Sementsov-Ogievskiy, 2020/09/18
[PATCH v6 13/15] scripts/simplebench: improve view of ascii table,
Vladimir Sementsov-Ogievskiy <=
[PATCH v6 15/15] scripts/simplebench: add bench_prealloc.py, Vladimir Sementsov-Ogievskiy, 2020/09/18
[PATCH v6 12/15] scripts/simplebench: support iops, Vladimir Sementsov-Ogievskiy, 2020/09/18
[PATCH v6 14/15] scripts/simplebench: improve ascii table: add difference line, Vladimir Sementsov-Ogievskiy, 2020/09/18