Skip to content

Commit 7052de9

Browse files
committed
Fix build-script -B
Without additional options, build-script -B was badly broken: * It added a broken --independent-samples option to the driver command line * Slow tests that ran only 1 sample by default would break the statistics Fix the first issue by adding `--independent-samples` to the command line only when a sample was actually provided by other options. Fix the second issue by including `--min-samples=2` in the command.
1 parent 5a2465e commit 7052de9

File tree

2 files changed

+28
-8
lines changed

2 files changed

+28
-8
lines changed

benchmark/cmake/modules/AddSwiftBenchmarkSuite.cmake

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -751,6 +751,26 @@ function(swift_benchmark_compile)
751751
DEPENDS ${platform_executables})
752752

753753
if(NOT SWIFT_BENCHMARK_BUILT_STANDALONE AND "${SWIFT_BENCHMARK_COMPILE_PLATFORM}" STREQUAL "macosx")
754+
set(SWIFT_BENCHMARK_ARGS)
755+
list(APPEND SWIFT_BENCHMARK_ARGS "--output-dir")
756+
list(APPEND SWIFT_BENCHMARK_ARGS "${CMAKE_CURRENT_BINARY_DIR}/logs")
757+
list(APPEND SWIFT_BENCHMARK_ARGS "--swift-repo")
758+
list(APPEND SWIFT_BENCHMARK_ARGS "${SWIFT_SOURCE_DIR}")
759+
list(APPEND SWIFT_BENCHMARK_ARGS "--architecture")
760+
list(APPEND SWIFT_BENCHMARK_ARGS "${arch}")
761+
762+
set(SWIFT_O_BENCHMARK_ARGS)
763+
if(DEFINED SWIFT_BENCHMARK_NUM_O_ITERATIONS)
764+
list(APPEND SWIFT_O_BENCHMARK_ARGS "--independent-samples")
765+
list(APPEND SWIFT_O_BENCHMARK_ARGS "${SWIFT_BENCHMARK_NUM_O_ITERATIONS}")
766+
endif()
767+
768+
set(SWIFT_ONONE_BENCHMARK_ARGS)
769+
if(DEFINED SWIFT_BENCHMARK_NUM_ONONE_ITERATIONS)
770+
list(APPEND SWIFT_O_BENCHMARK_ARGS "--independent-samples")
771+
list(APPEND SWIFT_O_BENCHMARK_ARGS "${SWIFT_BENCHMARK_NUM_ONONE_ITERATIONS}")
772+
endif()
773+
754774
add_custom_command(
755775
TARGET "${executable_target}"
756776
POST_BUILD
@@ -759,15 +779,13 @@ function(swift_benchmark_compile)
759779

760780
add_custom_target("check-${executable_target}"
761781
COMMAND "${swift-bin-dir}/Benchmark_Driver" "run"
762-
"-o" "O" "--output-dir" "${CMAKE_CURRENT_BINARY_DIR}/logs"
763-
"--architecture" "${arch}"
764-
"--swift-repo" "${SWIFT_SOURCE_DIR}"
765-
"--independent-samples" "${SWIFT_BENCHMARK_NUM_O_ITERATIONS}"
782+
"-o" "O"
783+
${SWIFT_BENCHMARK_ARGS}
784+
${SWIFT_O_BENCHMARK_ARGS}
766785
COMMAND "${swift-bin-dir}/Benchmark_Driver" "run"
767-
"-o" "Onone" "--output-dir" "${CMAKE_CURRENT_BINARY_DIR}/logs"
768-
"--swift-repo" "${SWIFT_SOURCE_DIR}"
769-
"--architecture" "${arch}"
770-
"--independent-samples" "${SWIFT_BENCHMARK_NUM_ONONE_ITERATIONS}"
786+
"-o" "Onone"
787+
${SWIFT_BENCHMARK_ARGS}
788+
${SWIFT_ONONE_BENCHMARK_ARGS}
771789
COMMAND "${swift-bin-dir}/Benchmark_Driver" "compare"
772790
"--log-dir" "${CMAKE_CURRENT_BINARY_DIR}/logs"
773791
"--swift-repo" "${SWIFT_SOURCE_DIR}"

benchmark/scripts/Benchmark_Driver

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,8 @@ class BenchmarkDriver(object):
226226
cmd.extend([str(self.test_number.get(name, name)) for name in self.tests])
227227
if num_samples > 0:
228228
cmd.append("--num-samples={0}".format(num_samples))
229+
else:
230+
cmd.append("--min-samples=2")
229231
if num_iters > 0:
230232
cmd.append("--num-iters={0}".format(num_iters))
231233
if sample_time > 0:

0 commit comments

Comments
 (0)