[commit: ghc] wip/perf-testsuite: Fix importing issue in testsuite driver (8cf1fe9)

git at git.haskell.org git at git.haskell.org
Sat Sep 2 21:46:08 UTC 2017


Repository : ssh://git@git.haskell.org/ghc

On branch  : wip/perf-testsuite
Link       : http://ghc.haskell.org/trac/ghc/changeset/8cf1fe907656d31ab0560e2c2007e599f41f7dc2/ghc

>---------------------------------------------------------------

commit 8cf1fe907656d31ab0560e2c2007e599f41f7dc2
Author: Jared Weakly <jweakly at pdx.edu>
Date:   Thu Aug 24 14:24:36 2017 -0700

    Fix importing issue in testsuite driver


>---------------------------------------------------------------

8cf1fe907656d31ab0560e2c2007e599f41f7dc2
 testsuite/driver/perf_notes.py | 39 ++++++++++++++++++++++-----------------
 testsuite/driver/testutil.py   | 22 +++++++++++++++++++++-
 2 files changed, 43 insertions(+), 18 deletions(-)

diff --git a/testsuite/driver/perf_notes.py b/testsuite/driver/perf_notes.py
index 92ec4bb..7fbea15 100644
--- a/testsuite/driver/perf_notes.py
+++ b/testsuite/driver/perf_notes.py
@@ -6,7 +6,6 @@
 # This file will be a utility to help facilitate the comparison of performance
 # metrics across arbitrary commits. The file will produce a table comparing
 # metrics between measurements taken for given commits in the environment given
-
 # by --test-env.
 
 import argparse
@@ -205,12 +204,12 @@ def evaluate_metric(test, field, deviation, contents):
 #
 # String utilities for pretty-printing
 #
-
-string = ''
-for i in args.commits:
-    string+='{:18}'
-commits = string.format(*[c[:10] for c in args.commits])
-latest_commit = [test for test in metrics if test['commit'] == args.commits[0]]
+def main_2():
+    string = ''
+    for i in args.commits:
+        string+='{:18}'
+    commits = string.format(*[c[:10] for c in args.commits])
+    latest_commit = [test for test in metrics if test['commit'] == args.commits[0]]
 
 def cmtline(insert):
     return string.format(*[insert for c in args.commits]).strip()
@@ -248,15 +247,21 @@ def commit_string(test, flag):
 # The pretty-printed output
 #
 
-header('commit')
-# Printing out metrics.
-for test in latest_commit:
-    print("{:27}{:30}".format(test['test'], test['metric']) + commit_string(test['test'],'metrics'))
+def main_3():
+    header('commit')
+    # Printing out metrics.
+    for test in latest_commit:
+        print("{:27}{:30}".format(test['test'], test['metric']) + commit_string(test['test'],'metrics'))
 
-# Has no meaningful output if there is no commit to compare to.
-if not singleton_commit:
-    header('percent')
+    # Has no meaningful output if there is no commit to compare to.
+    if not singleton_commit:
+        header('percent')
 
-    # Printing out percentages.
-    for test in latest_commit:
-        print("{:27}{:30}".format(test['test'], test['metric']) + commit_string(test['test'],'percentages'))
+        # Printing out percentages.
+        for test in latest_commit:
+            print("{:27}{:30}".format(test['test'], test['metric']) + commit_string(test['test'],'percentages'))
+
+if __name__ == '__main__':
+    main()
+    main_2()
+    main_3()
diff --git a/testsuite/driver/testutil.py b/testsuite/driver/testutil.py
index cc80b28..cb6ffe1 100644
--- a/testsuite/driver/testutil.py
+++ b/testsuite/driver/testutil.py
@@ -4,7 +4,6 @@ import platform
 import subprocess
 import shutil
 import threading
-from perf_notes import parse_git_notes
 
 def strip_quotes(s):
     # Don't wrap commands to subprocess.call/Popen in quotes.
@@ -47,6 +46,27 @@ def lndir(srcdir, dstdir):
             os.mkdir(dst)
             lndir(src, dst)
 
+
+# This function allows one to read in git notes from the commandline
+# and then breaks it into a list of dictionaries that can be parsed
+# later on in the testing functions.
+# Silently returns an empty string if the note is not found.
+def parse_git_notes(namespace, commit='HEAD'):
+    logFields = ['test_env','test','way','metric','value','commit']
+
+    try:
+        log = subprocess.check_output(['git', 'notes', '--ref=' + namespace, 'show', commit], stderr=subprocess.STDOUT).decode('utf-8')
+    except subprocess.CalledProcessError:
+        return []
+
+    log = log.strip('\n').split('\n')
+    log = list(filter(None, log))
+    log = [line.strip('\t').split('\t') for line in log]
+    [x.append(commit) for x in log]
+    log = [dict(zip(logFields, field)) for field in log]
+    return log
+
+
 # On Windows, os.symlink is not defined with Python 2.7, but is in Python 3
 # when using msys2, as GHC does. Unfortunately, only Administrative users have
 # the privileges necessary to create symbolic links by default. Consequently we



More information about the ghc-commits mailing list