Skip to content

Commit 4a71644

Browse files
committed
[benchmark] BernchmarkDriver run in batch mode
Finished support for running all active tests in one batch. Returns a dictionary of PerformanceTestResults. Known test names are passed to the harness in a compressed form as test numbers.
1 parent df33892 commit 4a71644

File tree

2 files changed

+29
-5
lines changed

2 files changed

+29
-5
lines changed

benchmark/scripts/Benchmark_Driver

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,12 +147,17 @@ class BenchmarkDriver(object):
147147
test, num_samples, num_iters, sample_time,
148148
verbose, measure_memory, quantile)
149149
output = self._invoke(cmd)
150-
result = self.parser.results_from_string(output).items()[0][1]
151-
return result
150+
results = self.parser.results_from_string(output)
151+
return results.items()[0][1] if test else results
152152

153153
def _cmd_run(self, test, num_samples, num_iters, sample_time,
154154
verbose, measure_memory, quantile):
155-
cmd = [self.test_harness, test]
155+
cmd = [self.test_harness]
156+
if test:
157+
cmd.append(test)
158+
else:
159+
cmd.extend([self.test_number.get(name, name)
160+
for name in self.tests])
156161
if num_samples > 0:
157162
cmd.append('--num-samples={0}'.format(num_samples))
158163
if num_iters > 0:
@@ -206,7 +211,6 @@ class BenchmarkDriver(object):
206211
from this method. When `csv_console` is False, the console output
207212
format is justified columns.
208213
"""
209-
210214
format = (
211215
(lambda values: ','.join(values)) if csv_console else
212216
(lambda values: self.RESULT.format(*values))) # justified columns

benchmark/scripts/test_Benchmark_Driver.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,9 +293,29 @@ def test_run_benchmark_in_verbose_mode(self):
293293
self.subprocess_mock.assert_called_with(
294294
('/benchmarks/Benchmark_O', 'b', '--verbose'))
295295

296+
def test_run_batch(self):
297+
"""Run all active tests in a single execution of the Benchmark_X.
298+
299+
Known test names are passed to the harness in a compressed form as test
300+
numbers.
301+
"""
302+
self.driver.tests = ['b1', 'bx']
303+
self.driver.run()
304+
self.subprocess_mock.assert_called_with(
305+
('/benchmarks/Benchmark_O', '1', 'bx'))
306+
296307
def test_parse_results_from_running_benchmarks(self):
297-
self.driver.run('b')
308+
"""Parse measurements results using LogParser.
309+
310+
Individual test run returns the first PerformanceTestResult directly.
311+
Batch run returns the dictionary of PerformanceTestResults.
312+
"""
313+
r = self.driver.run('b')
298314
self.assertTrue(self.parser_stub.results_from_string_called)
315+
self.assertEquals(r.name, 'b1') # non-matching name, just 1st result
316+
r = self.driver.run()
317+
self.assertTrue(isinstance(r, dict))
318+
self.assertEquals(r['b1'].name, 'b1')
299319

300320
def test_measure_memory(self):
301321
self.driver.run('b', measure_memory=True)

0 commit comments

Comments
 (0)