mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[benchmark] B_D iterations => independent-samples
Renamed Benchmark_Driver’s `iterations` argument to `independent-samples` to clarify its true meaning and disambiguate it from the concept of `num-iters` used in Benchmark_O. The short form of the argument — `-i` — remains unchanged.
This commit is contained in:
@@ -701,11 +701,11 @@ function(swift_benchmark_compile)
|
||||
COMMAND "${swift-bin-dir}/Benchmark_Driver" "run"
|
||||
"-o" "O" "--output-dir" "${CMAKE_CURRENT_BINARY_DIR}/logs"
|
||||
"--swift-repo" "${SWIFT_SOURCE_DIR}"
|
||||
"--iterations" "${SWIFT_BENCHMARK_NUM_O_ITERATIONS}"
|
||||
"--independent-samples" "${SWIFT_BENCHMARK_NUM_O_ITERATIONS}"
|
||||
COMMAND "${swift-bin-dir}/Benchmark_Driver" "run"
|
||||
"-o" "Onone" "--output-dir" "${CMAKE_CURRENT_BINARY_DIR}/logs"
|
||||
"--swift-repo" "${SWIFT_SOURCE_DIR}"
|
||||
"--iterations" "${SWIFT_BENCHMARK_NUM_ONONE_ITERATIONS}"
|
||||
"--independent-samples" "${SWIFT_BENCHMARK_NUM_ONONE_ITERATIONS}"
|
||||
COMMAND "${swift-bin-dir}/Benchmark_Driver" "compare"
|
||||
"--log-dir" "${CMAKE_CURRENT_BINARY_DIR}/logs"
|
||||
"--swift-repo" "${SWIFT_SOURCE_DIR}"
|
||||
|
||||
@@ -167,7 +167,7 @@ class BenchmarkDriver(object):
|
||||
|
||||
return reduce(merge_results,
|
||||
[self.run(test, measure_memory=True)
|
||||
for _ in range(self.args.iterations)])
|
||||
for _ in range(self.args.independent_samples)])
|
||||
|
||||
def log_results(self, output, log_file=None):
|
||||
"""Log output to `log_file`.
|
||||
@@ -603,7 +603,7 @@ def parse_args(args):
|
||||
help='Run benchmarks and output results to stdout',
|
||||
parents=[shared_benchmarks_parser])
|
||||
run_parser.add_argument(
|
||||
'-i', '--iterations',
|
||||
'-i', '--independent-samples',
|
||||
help='number of times to run each test (default: 1)',
|
||||
type=positive_int, default=1)
|
||||
run_parser.add_argument(
|
||||
|
||||
@@ -96,15 +96,16 @@ class Test_parse_args(unittest.TestCase):
|
||||
"(choose from 'O', 'Onone', 'Osize')"],
|
||||
err.getvalue())
|
||||
|
||||
def test_iterations(self):
|
||||
self.assertEquals(parse_args(['run']).iterations, 1)
|
||||
self.assertEquals(parse_args(['run', '-i', '3']).iterations, 3)
|
||||
def test_independent_samples(self):
|
||||
self.assertEquals(parse_args(['run']).independent_samples, 1)
|
||||
self.assertEquals(parse_args(['run', '-i', '3']).independent_samples,
|
||||
3)
|
||||
with captured_output() as (out, err):
|
||||
self.assertRaises(SystemExit,
|
||||
parse_args, ['run', '-i', '-3'])
|
||||
self.assert_contains(
|
||||
['error:',
|
||||
"argument -i/--iterations: invalid positive_int value: '-3'"],
|
||||
['error:', "argument -i/--independent-samples: " +
|
||||
"invalid positive_int value: '-3'"],
|
||||
err.getvalue())
|
||||
|
||||
def test_output_dir(self):
|
||||
@@ -279,7 +280,7 @@ class TestBenchmarkDriverRunningTests(unittest.TestCase):
|
||||
('/benchmarks/Benchmark_O', 'b', '--memory'))
|
||||
|
||||
def test_run_benchmark_independent_samples(self):
|
||||
self.driver.args.iterations = 3
|
||||
self.driver.args.independent_samples = 3
|
||||
r = self.driver.run_independent_samples('b1')
|
||||
self.assertEquals(self.subprocess_mock.calls.count(
|
||||
('/benchmarks/Benchmark_O', 'b1', '--memory')), 3)
|
||||
|
||||
Reference in New Issue
Block a user