From 1a90d76f7a2d215cc834d6267e9d3ff47f049b1a Mon Sep 17 00:00:00 2001
From: Dominic Kempf <dominic.kempf@iwr.uni-heidelberg.de>
Date: Fri, 28 Sep 2018 10:59:10 +0200
Subject: [PATCH] Reuse benchmark results

---
 python/dune/perftool/sumfact/autotune.py | 25 +++++++++++++-----------
 1 file changed, 14 insertions(+), 11 deletions(-)

diff --git a/python/dune/perftool/sumfact/autotune.py b/python/dune/perftool/sumfact/autotune.py
index 8199196f..9933e585 100644
--- a/python/dune/perftool/sumfact/autotune.py
+++ b/python/dune/perftool/sumfact/autotune.py
@@ -168,17 +168,20 @@ def autotune_realization(sf):
     filename = "{}.cc".format(name)
     logname = "{}.log".format(name)
 
-    # Generate and compile a benchmark program
-    with cache_restoring():
-        generate_standalone_code(sf, filename, logname)
-
-    ret = subprocess.call(compiler_invocation(name, filename))
-    assert ret == 0
-
-    # Run the benchmark program
-    devnull = open(os.devnull, 'w')
-    ret = subprocess.call(["./{}".format(name)], stdout=devnull, stderr=subprocess.STDOUT)
-    assert ret == 0
+    # If the log file already exists, we can reuse the benchmark results
+    # and do not need to rerun it.
+    if not os.path.isfile(logname):
+        # Generate and compile a benchmark program
+        with cache_restoring():
+            generate_standalone_code(sf, filename, logname)
+
+        ret = subprocess.call(compiler_invocation(name, filename))
+        assert ret == 0
+
+        # Run the benchmark program
+        devnull = open(os.devnull, 'w')
+        ret = subprocess.call(["./{}".format(name)], stdout=devnull, stderr=subprocess.STDOUT)
+        assert ret == 0
 
     # Extract the result form the log file
     return float(next(iter(open(logname, "r")))) / 1000000
-- 
GitLab