[test-suite] r251891 - cmake/lit: Separate addMetric() calls from code collecting exectime and compiletime

Matthias Braun via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 2 18:46:58 PST 2015


Author: matze
Date: Mon Nov  2 20:46:58 2015
New Revision: 251891

URL: http://llvm.org/viewvc/llvm-project?rev=251891&view=rev
Log:
cmake/lit: Separate addMetric() calls from code collecting exectime and compiletime

Modified:
    test-suite/trunk/lit.cfg

Modified: test-suite/trunk/lit.cfg
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/lit.cfg?rev=251891&r1=251890&r2=251891&view=diff
==============================================================================
--- test-suite/trunk/lit.cfg (original)
+++ test-suite/trunk/lit.cfg Mon Nov  2 20:46:58 2015
@@ -61,18 +61,16 @@ def getUserTimeFromTimeOutput(f):
     m = re.match(r'user\s+([0-9.]+)', l[0])
     return float(m.group(1))
 
-def collectTimes(test, timefile, result):
-    time = getUserTimeFromTimeOutput(timefile)
-    result.addMetric('exec_time', lit.Test.toMetricValue(time))
-
-    # For completeness, attempt to find compile time information too.
+def collectCompileTime(test):
+    # TODO: This is not correct yet as the directory may contain .o.time files
+    # of multiple benchmarks in the case of SingleSource tests.
     compile_time = 0.0
     basepath = os.path.dirname(test.getFilePath())
     for path, subdirs, files in os.walk(basepath):
         for file in files:
             if file.endswith('.o.time'):
                 compile_time += getUserTimeFromTimeOutput(os.path.join(path, file))
-    result.addMetric('compile_time', lit.Test.toMetricValue(compile_time))
+    return compile_time
 
 def runScript(test, litConfig, script, tmpBase, useExternalSh = False):
     # Create the output directory if it does not already exist.
@@ -150,19 +148,24 @@ class TestSuiteTest(FileBasedTest):
 
         # Run RUN: part of the script n times
         n_runs = 1
+        runtimes = []
         for n in range(n_runs):
             runresult = runScript(test, litConfig, runscript, tmpBase)
             if runresult.code == Test.FAIL:
                 return runresult
             timefile = "%s.time" % (outfile,)
-            collectTimes(test, timefile, runresult)
-            # TODO: aggregate times of multiple runs
+            runtime = getUserTimeFromTimeOutput(timefile)
+            runtimes.append(runtime)
 
         # Run verification of results
         verifyresult = runScript(test, litConfig, verifyscript, tmpBase)
         if verifyresult.code == Test.FAIL:
             return verifyresult
 
+        compile_time = collectCompileTime(test)
+
+        runresult.addMetric('exec_time', lit.Test.toMetricValue(runtimes[0]))
+        runresult.addMetric('compile_time', lit.Test.toMetricValue(compile_time))
         return runresult
 
 config.name = 'test-suite'




More information about the llvm-commits mailing list