Browse Source

Faster test gathering

Replaces os.walk with glob
Addresses #614
Hamilton Turner 11 years ago
parent
commit
c0ddc2a092
1 changed files with 17 additions and 16 deletions
  1. 17 16
      toolset/benchmark/benchmarker.py

+ 17 - 16
toolset/benchmark/benchmarker.py

@@ -11,6 +11,7 @@ import csv
 import sys
 import logging
 import socket
+import glob
 from multiprocessing import Process
 from datetime import datetime
 
@@ -243,9 +244,11 @@ class Benchmarker:
   @property
   def __gather_tests(self):
     tests = []
-    # Loop through each directory (we assume we're being run from the benchmarking root)
-    # and look for the files that signify a benchmark test
-    for dirname, dirnames, filenames in os.walk('.'):
+
+    # Assume we are running from FrameworkBenchmarks
+    config_files = glob.glob('*/benchmark_config')
+
+    for config_file_name in config_files:
       # Look for the benchmark_config file, this will set up our tests.
       # Its format looks like this:
       #
@@ -264,22 +267,20 @@ class Benchmarker:
       #     ...
       #   }]
       # }
-      if 'benchmark_config' in filenames:
-        config = None
-        config_file_name = os.path.join(dirname, 'benchmark_config')
+      config = None
 
-        with open(config_file_name, 'r') as config_file:
-          # Load json file into config object
-          try:
-            config = json.load(config_file)
-          except:
-            print("Error loading '%s'." % config_file_name)
-            raise
+      with open(config_file_name, 'r') as config_file:
+        # Load json file into config object
+        try:
+          config = json.load(config_file)
+        except:
+          print("Error loading '%s'." % config_file_name)
+          raise
 
-        if config == None:
-          continue
+      if config is None:
+        continue
 
-        tests = tests + framework_test.parse_config(config, dirname[2:], self)
+      tests = tests + framework_test.parse_config(config, os.path.dirname(config_file_name), self)
 
     tests.sort(key=lambda x: x.name)
     return tests