about summary refs log tree commit diff
path: root/benchtests/scripts/import_bench.py
diff options
context:
space:
mode:
authorSiddhesh Poyarekar <siddhesh@redhat.com>2015-06-01 23:13:29 +0530
committerSiddhesh Poyarekar <siddhesh@redhat.com>2015-06-01 23:13:29 +0530
commit0994b9b6f685d460ee72170824a5393b592dc3c5 (patch)
treeda45b4e4391ec4a35a0b83883d931e35e8ab2b03 /benchtests/scripts/import_bench.py
parent2483fa850f86a2edec705aaeb2ca84414d6e1367 (diff)
downloadglibc-0994b9b6f685d460ee72170824a5393b592dc3c5.tar.gz
glibc-0994b9b6f685d460ee72170824a5393b592dc3c5.tar.xz
glibc-0994b9b6f685d460ee72170824a5393b592dc3c5.zip
New module to import and process benchmark output
This is the beginning of a module to import and process benchmark
outputs.  The module currently supports importing of a bench.out and
validating it against a schema file.  In future this could grow a set
of routines that benchmark consumers may find useful to build their
own analysis tools.  I have altered validate_bench to use this module
too.

	* benchtests/scripts/import_bench.py: New file.
	* benchtests/scripts/validate_benchout.py: Import import_bench
	instead of jsonschema.
	(validate_bench): Remove function.
	(main): Use import_bench.
Diffstat (limited to 'benchtests/scripts/import_bench.py')
-rw-r--r--benchtests/scripts/import_bench.py45
1 files changed, 45 insertions, 0 deletions
diff --git a/benchtests/scripts/import_bench.py b/benchtests/scripts/import_bench.py
new file mode 100644
index 0000000000..81248c2adf
--- /dev/null
+++ b/benchtests/scripts/import_bench.py
@@ -0,0 +1,45 @@
+#!/usr/bin/python
+# Copyright (C) 2015 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+#
+# 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
+# <http://www.gnu.org/licenses/>.
+"""Functions to import benchmark data and process it"""
+
+import json
+try:
+    import jsonschema as validator
+except ImportError:
+    print('Could not find jsonschema module.')
+    raise
+
+
+def parse_bench(filename, schema_filename):
+    """Parse the input file
+
+    Parse and validate the json file containing the benchmark outputs.  Return
+    the resulting object.
+    Args:
+        filename: Name of the benchmark output file.
+    Return:
+        The bench dictionary.
+    """
+    with open(schema_filename, 'r') as schemafile:
+        schema = json.load(schemafile)
+        with open(filename, 'r') as benchfile:
+            bench = json.load(benchfile)
+            validator.validate(bench, schema)
+            do_for_all_timings(bench, lambda b, f, v:
+                    b['functions'][f][v]['timings'].sort())
+            return bench