Browse Source

Fix commit counting

Fixes TechEmpower/FrameworkBenchmarks#1113
Hamilton Turner 10 years ago
parent
commit
6b29b651c2
2 changed files with 20 additions and 6 deletions
  1. 5 5
      toolset/benchmark/benchmarker.py
  2. 15 1
      toolset/benchmark/utils.py

+ 5 - 5
toolset/benchmark/benchmarker.py

@@ -4,6 +4,7 @@ from setup.linux import setup_util
 from benchmark import framework_test
 from utils import header
 from utils import gather_tests
+from utils import gather_frameworks
 
 import os
 import json
@@ -767,16 +768,15 @@ class Benchmarker:
   # __count_commits
   ############################################################
   def __count_commits(self):
-    all_frameworks = self.__gather_frameworks()
+    frameworks = gather_frameworks(benchmarker=self)
 
     jsonResult = {}
-
-    for framework in all_frameworks:
+    for framework, testlist in frameworks.iteritems():
+      command = "git rev-list HEAD -- " + testlist[0].directory + " | sort -u | wc -l"
       try:
-        command = "git rev-list HEAD -- " + framework + " | sort -u | wc -l"
         commitCount = subprocess.check_output(command, shell=True)
         jsonResult[framework] = int(commitCount)
-      except:
+      except subprocess.CalledProcessError:
         continue
 
     self.results['rawData']['commitCounts'] = jsonResult

+ 15 - 1
toolset/benchmark/utils.py

@@ -62,7 +62,7 @@ def gather_tests(include = [], exclude=[], benchmarker=None):
     with open(config_file_name, 'r') as config_file:
       try:
         config = json.load(config_file)
-      except:
+      except ValueError:
         # User-friendly errors
         print("Error loading '%s'." % config_file_name)
         raise
@@ -81,6 +81,20 @@ def gather_tests(include = [], exclude=[], benchmarker=None):
   tests.sort(key=lambda x: x.name)
   return tests
 
+def gather_frameworks(include = [], exclude=[], benchmarker=None):
+  '''Return a dictionary mapping frameworks->[test1,test2,test3]
+  for quickly grabbing all tests in a grouped manner. 
+  Args have the same meaning as gather_tests'''
+
+  tests = gather_tests(include, exclude, benchmarker)
+  frameworks = dict()
+
+  for test in tests:
+    if test.framework not in frameworks: 
+      frameworks[test.framework] = []
+    frameworks[test.framework].append(test)
+  return frameworks
+
 def header(message, top='-', bottom='-'):
     '''
     Generates a clean header