[test-suite] r313710 - litsupport: Do lit.Test.toMetricValue() in a central place

Matthias Braun via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 19 20:00:04 PDT 2017


Author: matze
Date: Tue Sep 19 20:00:04 2017
New Revision: 313710

URL: http://llvm.org/viewvc/llvm-project?rev=313710&view=rev
Log:
litsupport: Do lit.Test.toMetricValue() in a central place

Every metric collector was calling lit.Test.toMetricValue() and I don't
see a reason to do anything else. So instead we can just always do this
for the results of a metric collector and don't need to do it in
independently in every metric collector.

Modified:
    test-suite/trunk/litsupport/codesize.py
    test-suite/trunk/litsupport/compiletime.py
    test-suite/trunk/litsupport/hash.py
    test-suite/trunk/litsupport/perf.py
    test-suite/trunk/litsupport/profilegen.py
    test-suite/trunk/litsupport/stats.py
    test-suite/trunk/litsupport/testplan.py
    test-suite/trunk/litsupport/timeit.py

Modified: test-suite/trunk/litsupport/codesize.py
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/litsupport/codesize.py?rev=313710&r1=313709&r2=313710&view=diff
==============================================================================
--- test-suite/trunk/litsupport/codesize.py (original)
+++ test-suite/trunk/litsupport/codesize.py Tue Sep 19 20:00:04 2017
@@ -1,15 +1,13 @@
 """Test module to collect code size metrics of the benchmark executable."""
 from litsupport import testplan
-import lit.Test
 import logging
 import os.path
 
 
 def _getCodeSize(context):
-    size = os.path.getsize(context.executable)
     # First get the filesize: This should always work.
     metrics = {}
-    metrics['size'] = lit.Test.toMetricValue(size)
+    metrics['size'] = os.path.getsize(context.executable)
 
     # If we have the llvm-size tool available get the size per segment.
     llvm_size = context.config.llvm_size
@@ -37,7 +35,7 @@ def _getCodeSize(context):
                 try:
                     name = values[0]
                     val = int(values[1])
-                    metrics['size.%s' % name] = lit.Test.toMetricValue(val)
+                    metrics['size.%s' % name] = val
                 except ValueError as e:
                     logging.info("Ignoring malformed output line: %s", l)
 

Modified: test-suite/trunk/litsupport/compiletime.py
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/litsupport/compiletime.py?rev=313710&r1=313709&r2=313710&view=diff
==============================================================================
--- test-suite/trunk/litsupport/compiletime.py (original)
+++ test-suite/trunk/litsupport/compiletime.py Tue Sep 19 20:00:04 2017
@@ -1,6 +1,5 @@
 """Test module to collect compile time metrics. This just finds and summarizes
 the *.time files generated by the build."""
-import lit.Test
 from litsupport import timeit
 import os
 
@@ -24,8 +23,8 @@ def _getCompileTime(context):
                 fullpath = os.path.join(path, file)
                 link_time += timeit.getUserTime(fullpath)
     return {
-        'compile_time': lit.Test.toMetricValue(compile_time),
-        'link_time': lit.Test.toMetricValue(link_time),
+        'compile_time': compile_time,
+        'link_time': link_time,
     }
 
 

Modified: test-suite/trunk/litsupport/hash.py
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/litsupport/hash.py?rev=313710&r1=313709&r2=313710&view=diff
==============================================================================
--- test-suite/trunk/litsupport/hash.py (original)
+++ test-suite/trunk/litsupport/hash.py Tue Sep 19 20:00:04 2017
@@ -1,9 +1,7 @@
 """Test module to collect test executable hashsum."""
-from lit.Test import toMetricValue
 from litsupport import shellcommand
 from litsupport import testplan
 import hashlib
-import lit.Test
 import logging
 import platform
 
@@ -50,7 +48,7 @@ def same_as_previous(context):
 
 def _getHash(context):
     compute(context)
-    return {'hash': lit.Test.toMetricValue(context.executable_hash)}
+    return {'hash': context.executable_hash}
 
 
 def mutatePlan(context, plan):

Modified: test-suite/trunk/litsupport/perf.py
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/litsupport/perf.py?rev=313710&r1=313709&r2=313710&view=diff
==============================================================================
--- test-suite/trunk/litsupport/perf.py (original)
+++ test-suite/trunk/litsupport/perf.py Tue Sep 19 20:00:04 2017
@@ -3,7 +3,6 @@ perf tool."""
 from litsupport import shellcommand
 from litsupport import testplan
 from litsupport import run_under
-import lit.Test
 
 
 def _mutateCommandLine(context, commandline):
@@ -34,5 +33,4 @@ def mutatePlan(context, plan):
     script = testplan.mutateScript(context, script, _mutateCommandLine)
     plan.profilescript += script
     plan.metric_collectors.append(
-        lambda context: {
-            'profile': lit.Test.toMetricValue(context.tmpBase + '.perf_data')})
+        lambda context: {'profile': context.tmpBase + '.perf_data'})

Modified: test-suite/trunk/litsupport/profilegen.py
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/litsupport/profilegen.py?rev=313710&r1=313709&r2=313710&view=diff
==============================================================================
--- test-suite/trunk/litsupport/profilegen.py (original)
+++ test-suite/trunk/litsupport/profilegen.py Tue Sep 19 20:00:04 2017
@@ -18,7 +18,7 @@ def _mutateScript(context, script):
 
 def mutatePlan(context, plan):
     context.profilefiles = []
-    # Adjust run steps to set LLVM_PROFILE_FILE
+    # Adjust run steps to set LLVM_PROFILE_FILE environment variable.
     plan.runscript = _mutateScript(context, plan.runscript)
     # Run profdata merge at the end
     profdatafile = context.executable + ".profdata"

Modified: test-suite/trunk/litsupport/stats.py
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/litsupport/stats.py?rev=313710&r1=313709&r2=313710&view=diff
==============================================================================
--- test-suite/trunk/litsupport/stats.py (original)
+++ test-suite/trunk/litsupport/stats.py Tue Sep 19 20:00:04 2017
@@ -2,7 +2,6 @@
 
 This assumes the benchmarks were built with the -save-stats=obj flag."""
 import json
-import lit.Test
 import logging
 import os
 from collections import defaultdict
@@ -39,7 +38,7 @@ def _getStats(context):
 
     result = dict()
     for key, value in stats.iteritems():
-        result[key] = lit.Test.toMetricValue(value)
+        result[key] = value
     return result
 
 

Modified: test-suite/trunk/litsupport/testplan.py
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/litsupport/testplan.py?rev=313710&r1=313709&r2=313710&view=diff
==============================================================================
--- test-suite/trunk/litsupport/testplan.py (original)
+++ test-suite/trunk/litsupport/testplan.py Tue Sep 19 20:00:04 2017
@@ -116,7 +116,8 @@ def _executePlan(context, plan):
         try:
             additional_metrics = metric_collector(context)
             for metric, value in additional_metrics.items():
-                context.result_metrics[metric] = value
+                litvalue = lit.Test.toMetricValue(value)
+                context.result_metrics[metric] = litvalue
         except Exception as e:
             logging.error("Could not collect metric with %s", metric_collector,
                           exc_info=e)

Modified: test-suite/trunk/litsupport/timeit.py
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/litsupport/timeit.py?rev=313710&r1=313709&r2=313710&view=diff
==============================================================================
--- test-suite/trunk/litsupport/timeit.py (original)
+++ test-suite/trunk/litsupport/timeit.py Tue Sep 19 20:00:04 2017
@@ -1,6 +1,5 @@
 from litsupport import shellcommand
 from litsupport import testplan
-import lit.Test
 import re
 
 
@@ -57,7 +56,7 @@ def _collectTime(context, timefiles, met
     time = 0.0
     for timefile in timefiles:
         time += getUserTime(timefile)
-    return {metric_name: lit.Test.toMetricValue(time)}
+    return {metric_name: time}
 
 
 def mutatePlan(context, plan):




More information about the llvm-commits mailing list