diff --git a/python/dune/perftool/sumfact/autotune.py b/python/dune/perftool/sumfact/autotune.py index 8199196f25392bab32518b7220a7026b16edfbc0..9933e5852e13cc9182a358e6799094ceeedf64fc 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