r344990 - [analyzer] [testing] Compute data on path length, compute percentiles

George Karpenkov via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 22 18:30:26 PDT 2018


Author: george.karpenkov
Date: Mon Oct 22 18:30:26 2018
New Revision: 344990

URL: http://llvm.org/viewvc/llvm-project?rev=344990&view=rev
Log:
[analyzer] [testing] Compute data on path length, compute percentiles

Differential Revision: https://reviews.llvm.org/D52844

Modified:
    cfe/trunk/utils/analyzer/CmpRuns.py

Modified: cfe/trunk/utils/analyzer/CmpRuns.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/analyzer/CmpRuns.py?rev=344990&r1=344989&r2=344990&view=diff
==============================================================================
--- cfe/trunk/utils/analyzer/CmpRuns.py (original)
+++ cfe/trunk/utils/analyzer/CmpRuns.py Mon Oct 22 18:30:26 2018
@@ -281,9 +281,21 @@ def compareResults(A, B, opts):
 
     return res
 
+def computePercentile(l, percentile):
+    """
+    Return computed percentile.
+    """
+    return sorted(l)[int(round(percentile * len(l) + 0.5)) - 1]
+
 def deriveStats(results):
     # Assume all keys are the same in each statistics bucket.
     combined_data = defaultdict(list)
+
+    # Collect data on paths length.
+    for report in results.reports:
+        for diagnostic in report.diagnostics:
+            combined_data['PathsLength'].append(diagnostic.getPathLength())
+
     for stat in results.stats:
         for key, value in stat.iteritems():
             combined_data[key].append(value)
@@ -293,6 +305,8 @@ def deriveStats(results):
             "max": max(values),
             "min": min(values),
             "mean": sum(values) / len(values),
+            "90th %tile": computePercentile(values, 0.9),
+            "95th %tile": computePercentile(values, 0.95),
             "median": sorted(values)[len(values) / 2],
             "total": sum(values)
         }




More information about the cfe-commits mailing list