Skip to content

Commit cd4886a

Browse files
committed
[Gardening] Move imports and DriverArgs to top
1 parent 4a71644 commit cd4886a

File tree

1 file changed

+20
-18
lines changed

1 file changed

+20
-18
lines changed

benchmark/scripts/run_smoke_bench

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,29 @@ import sys
3232

3333
from compare_perf_tests import LogParser, create_report
3434

35+
from imp import load_source
36+
# import Benchmark_Driver # doesn't work because it misses '.py' extension
37+
Benchmark_Driver = load_source(
38+
'Benchmark_Driver', os.path.join(os.path.dirname(
39+
os.path.abspath(__file__)), 'Benchmark_Driver'))
40+
# from Benchmark_Driver import BenchmarkDriver, BenchmarkDoctor, ...
41+
BenchmarkDriver = Benchmark_Driver.BenchmarkDriver
42+
BenchmarkDoctor = Benchmark_Driver.BenchmarkDoctor
43+
MarkdownReportHandler = Benchmark_Driver.MarkdownReportHandler
44+
3545
VERBOSE = False
3646

3747

48+
class DriverArgs(object):
49+
"""Arguments for BenchmarkDriver."""
50+
def __init__(self, tests, optimization='O'):
51+
"""Initialize with path to the build-dir and optimization level."""
52+
self.benchmarks = None
53+
self.filters = None
54+
self.tests = os.path.join(tests, 'bin')
55+
self.optimization = optimization
56+
57+
3858
def log(msg):
3959
print(msg)
4060
sys.stdout.flush()
@@ -332,25 +352,7 @@ performance team (@eeckstein).
332352
return text
333353

334354

335-
class DriverArgs(object):
336-
def __init__(self, tests):
337-
self.benchmarks = None
338-
self.filters = None
339-
self.tests = os.path.join(tests, 'bin')
340-
self.optimization = 'O'
341-
342-
343355
def check_added(args, output_file=None):
344-
from imp import load_source
345-
# import Benchmark_Driver # doesn't work because it misses '.py' extension
346-
Benchmark_Driver = load_source(
347-
'Benchmark_Driver', os.path.join(os.path.dirname(
348-
os.path.abspath(__file__)), 'Benchmark_Driver'))
349-
# from Benchmark_Driver import BenchmarkDriver, BenchmarkDoctor
350-
BenchmarkDriver = Benchmark_Driver.BenchmarkDriver
351-
BenchmarkDoctor = Benchmark_Driver.BenchmarkDoctor
352-
MarkdownReportHandler = Benchmark_Driver.MarkdownReportHandler
353-
354356
old = BenchmarkDriver(DriverArgs(args.oldbuilddir[0]))
355357
new = BenchmarkDriver(DriverArgs(args.newbuilddir[0]))
356358
added = set(new.tests).difference(set(old.tests))

0 commit comments

Comments
 (0)