r324021 - [analyzer] [tests] Add an option to show the histogram of path differences between the analyzer runs
George Karpenkov via cfe-commits
cfe-commits at lists.llvm.org
Thu Feb 1 14:25:18 PST 2018
Author: george.karpenkov
Date: Thu Feb 1 14:25:18 2018
New Revision: 324021
URL: http://llvm.org/viewvc/llvm-project?rev=324021&view=rev
Log:
[analyzer] [tests] Add an option to show the histogram of path differences between the analyzer runs
Differential Revision: https://reviews.llvm.org/D42778
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=324021&r1=324020&r2=324021&view=diff
==============================================================================
--- cfe/trunk/utils/analyzer/CmpRuns.py (original)
+++ cfe/trunk/utils/analyzer/CmpRuns.py Thu Feb 1 14:25:18 2018
@@ -28,6 +28,7 @@ Usage:
import os
import plistlib
+from math import log
# Information about analysis run:
@@ -47,6 +48,7 @@ class AnalysisDiagnostic:
self._loc = self._data['location']
self._report = report
self._htmlReport = htmlReport
+ self._reportSize = len(self._data['path'])
def getFileName(self):
root = self._report.run.root
@@ -61,6 +63,9 @@ class AnalysisDiagnostic:
def getColumn(self):
return self._loc['col']
+ def getPathLength(self):
+ return self._reportSize
+
def getCategory(self):
return self._data['category']
@@ -193,7 +198,7 @@ def cmpAnalysisDiagnostic(d):
return d.getIssueIdentifier()
-def compareResults(A, B):
+def compareResults(A, B, opts):
"""
compareResults - Generate a relation from diagnostics in run A to
diagnostics in run B.
@@ -206,6 +211,9 @@ def compareResults(A, B):
res = []
+ # Map size_before -> size_after
+ path_difference_data = []
+
# Quickly eliminate equal elements.
neqA = []
neqB = []
@@ -217,6 +225,17 @@ def compareResults(A, B):
a = eltsA.pop()
b = eltsB.pop()
if (a.getIssueIdentifier() == b.getIssueIdentifier()):
+ if a.getPathLength() != b.getPathLength():
+ if opts.relative_path_histogram:
+ path_difference_data.append(
+ float(a.getPathLength()) / b.getPathLength())
+ elif opts.relative_log_path_histogram:
+ path_difference_data.append(
+ log(float(a.getPathLength()) / b.getPathLength()))
+ elif opts.absolute_path_histogram:
+ path_difference_data.append(
+ a.getPathLength() - b.getPathLength())
+
res.append((a, b, 0))
elif a.getIssueIdentifier() > b.getIssueIdentifier():
eltsB.append(b)
@@ -238,6 +257,12 @@ def compareResults(A, B):
for b in neqB:
res.append((None, b, None))
+ if opts.relative_log_path_histogram or opts.relative_path_histogram or \
+ opts.absolute_path_histogram:
+ from matplotlib import pyplot
+ pyplot.hist(path_difference_data, bins=100)
+ pyplot.show()
+
return res
@@ -252,7 +277,7 @@ def dumpScanBuildResultsDiff(dirA, dirB,
else:
auxLog = None
- diff = compareResults(resultsA, resultsB)
+ diff = compareResults(resultsA, resultsB, opts)
foundDiffs = 0
totalAdded = 0
totalRemoved = 0
@@ -314,6 +339,21 @@ def main():
[default=None]",
action="store", type=str, default=None,
metavar="LOG")
+ parser.add_option("--relative-path-differences-histogram",
+ action="store_true", dest="relative_path_histogram",
+ default=False,
+ help="Show histogram of relative paths differences. \
+ Requires matplotlib")
+ parser.add_option("--relative-log-path-differences-histogram",
+ action="store_true", dest="relative_log_path_histogram",
+ default=False,
+ help="Show histogram of log relative paths differences. \
+ Requires matplotlib")
+ parser.add_option("--absolute-path-differences-histogram",
+ action="store_true", dest="absolute_path_histogram",
+ default=False,
+ help="Show histogram of absolute paths differences. \
+ Requires matplotlib")
(opts, args) = parser.parse_args()
if len(args) != 2:
More information about the cfe-commits
mailing list