[PATCH v2 3/5] benchtests: Add a script to convert benchout string JSON to CSV
Naohiro Tamura
naohirot@fujitsu.com
Tue Jul 20 06:35:40 GMT 2021
This patch adds "benchout_string2csv.sh" script to convert benchout
string JSON to CSV so that we can visualize performance data by any
spreadsheet such as MS Excel and Google Sheet.
Usage: benchout_string2csv.sh
read benchout string JSON from standard input
write CSV to standard output
ex:
$ cat bench-memset.out | benchout_string2csv.sh > bench-memset.csv
---
benchtests/scripts/benchout_string2csv.sh | 44 +++++++++++++++++++++++
1 file changed, 44 insertions(+)
create mode 100755 benchtests/scripts/benchout_string2csv.sh
diff --git a/benchtests/scripts/benchout_string2csv.sh b/benchtests/scripts/benchout_string2csv.sh
new file mode 100755
index 000000000000..045870fed162
--- /dev/null
+++ b/benchtests/scripts/benchout_string2csv.sh
@@ -0,0 +1,44 @@
+#!/bin/bash
+# Copyright (C) 2021 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+# Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, see
+# <https://www.gnu.org/licenses/>.
+
+#
+# Convert benchout string JSON to CSV
+#
+if [[ $1 == "-h" ]] || [[ $# != 0 ]]; then
+ echo "Usage: ${0##*/}"
+ echo " read benchout string JSON from standard input"
+ echo " write CSV to standard output"
+ echo "ex:"
+ echo " $ cat bench-memset.out | ${0##*/} > bench-memset.csv"
+exit 1
+fi
+
+jq -r '
+ . as $root |
+ . as {$functions} |
+ $functions | to_entries | .[0].value as $func_value |
+ $func_value as {$_, $ifuncs, $results} |
+ (["timing_type", $root.timing_type] | @csv),
+ (["functions", ($functions | keys | .[0]),
+ "bench-variant", $func_value."bench-variant"] | @csv),
+ ($results[0] | to_entries | map([.key]) | flatten | @csv),
+ ($results[0] | reduce range(1; . | length) as $_ ([]; . + [""])
+ + $ifuncs | @csv),
+ ($results[] | to_entries | map([.value]) | flatten | @csv)
+'
--
2.17.1
More information about the Libc-alpha
mailing list