From a5991543dffcb6087a95afc1c7cfe2742636d03d Mon Sep 17 00:00:00 2001
From: Christian Dietrich <christian.dietrich@informatik.uni-erlangen.de>
Date: Mon, 13 Feb 2017 12:46:58 +0100
Subject: [PATCH] More output in analyze

---
 experiments/analyze_results.py | 36 +++++++++++++++++++++-------------
 1 file changed, 22 insertions(+), 14 deletions(-)

diff --git a/experiments/analyze_results.py b/experiments/analyze_results.py
index ec04cc0..831e8ad 100755
--- a/experiments/analyze_results.py
+++ b/experiments/analyze_results.py
@@ -103,11 +103,18 @@ class AnalyzeResults(Experiment):
 
                 build_times = []
                 failed = 0
+                i = 0
+                last_failed = 0
                 for build in records['builds']:
+
+                    i += 1
                     if build.get('failed'):
                         failed += 1
+                        last_failed = i
                         continue
                     t = build['build-time']/1e9
+                    build['id'] = i
+                    build['last failed'] = last_failed
                     build_times.append(t)
                     times[build['commit']][result.metadata['mode']] = t
                     hist[int(t)] += 1
@@ -127,6 +134,8 @@ class AnalyzeResults(Experiment):
 
                     stats['compiler calls'] = stats['hits'] + stats['misses']
 
+                    assert misses >= 0, build
+
                     build['hits'] = hits
                     build['misses'] = misses
                     build['compiler calls'] = hits + misses
@@ -147,8 +156,8 @@ class AnalyzeResults(Experiment):
                     method_stats[result.metadata["mode"]][k] += stats[k]
 
             try:
-                x = sorted(times, key=lambda x: times[x]['normal'])
-                #print(project, x[0], times[x[0]]['normal'], HITS[x[0]])
+                x = sorted(times, key=lambda x: times[x].get('clang-hash', float("NaN"))/times[x]['normal'])
+                print(project, x[0], times[x[0]]['clang-hash']/times[x[0]]['normal'], HITS[x[0]])
                 #print(project, x[-1], times[x[-1]]['normal'], HITS[x[-1]])
                 #print "------"
 
@@ -156,7 +165,8 @@ class AnalyzeResults(Experiment):
                 for k in ("normal", "ccache", "clang-hash", "ccache-clang-hash"):
                     self.save([project, "best commit", k], times[x[0]][k])
                 self.save([project, "best commit", "ratio"], times[x[0]]['clang-hash']/times[x[0]]['normal'])
-            except:
+            except RuntimeError as e:
+                print(e)
                 pass
 
         # Output method statistics
@@ -164,19 +174,17 @@ class AnalyzeResults(Experiment):
             for k in method_stats[method]:
                 self.save([method, "historical", k], method_stats[method][k])
 
-        for Hash in HITS:
-            #if Hash != "fe0a0b5993dfe24e4b3bcf52fa64ff41a444b8f1":
-            #    continue
-            #print HITS[Hash]
+
+        for Hash in sorted(HITS, key = lambda H: HITS[H]['ccache']['id']):
             continue
-            if 'clang-hash' not in HITS[Hash]:
+            #print HITS[Hash]
+            #if 'clang-hash' not in HITS[Hash]:
+            #    continue
+            delta = HITS[Hash]['clang-hash']['compiler calls'] - HITS[Hash]['ccache']['compiler calls']
+            if delta < 0:
+                print Hash, HITS[Hash]['ccache']['id'], HITS[Hash]['clang-hash']['id'], HITS[Hash]['ccache']['last failed'], delta
                 continue
-            if HITS[Hash]['clang-hash']['hits'] \
-               > HITS[Hash]['ccache-clang-hash']['hits']:
-                print Hash, \
-                    (HITS[Hash]['clang-hash']['hits'],
-                     HITS[Hash]['ccache-clang-hash']['hits'])
-                for i in ("clang-hash", "ccache-clang-hash"):
+                for i in ("clang-hash", "ccache"):
                     print i, HITS[Hash][i]
 
                 print "-----"
-- 
GitLab