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.
This commit is contained in:
Tim Kientzle
2023-09-22 17:44:42 -07:00
parent 5a2465efed
commit 7052de9399
2 changed files with 28 additions and 8 deletions

View File

@@ -751,6 +751,26 @@ function(swift_benchmark_compile)
DEPENDS ${platform_executables})
if(NOT SWIFT_BENCHMARK_BUILT_STANDALONE AND "${SWIFT_BENCHMARK_COMPILE_PLATFORM}" STREQUAL "macosx")
set(SWIFT_BENCHMARK_ARGS)
list(APPEND SWIFT_BENCHMARK_ARGS "--output-dir")
list(APPEND SWIFT_BENCHMARK_ARGS "${CMAKE_CURRENT_BINARY_DIR}/logs")
list(APPEND SWIFT_BENCHMARK_ARGS "--swift-repo")
list(APPEND SWIFT_BENCHMARK_ARGS "${SWIFT_SOURCE_DIR}")
list(APPEND SWIFT_BENCHMARK_ARGS "--architecture")
list(APPEND SWIFT_BENCHMARK_ARGS "${arch}")
set(SWIFT_O_BENCHMARK_ARGS)
if(DEFINED SWIFT_BENCHMARK_NUM_O_ITERATIONS)
list(APPEND SWIFT_O_BENCHMARK_ARGS "--independent-samples")
list(APPEND SWIFT_O_BENCHMARK_ARGS "${SWIFT_BENCHMARK_NUM_O_ITERATIONS}")
endif()
set(SWIFT_ONONE_BENCHMARK_ARGS)
if(DEFINED SWIFT_BENCHMARK_NUM_ONONE_ITERATIONS)
list(APPEND SWIFT_O_BENCHMARK_ARGS "--independent-samples")
list(APPEND SWIFT_O_BENCHMARK_ARGS "${SWIFT_BENCHMARK_NUM_ONONE_ITERATIONS}")
endif()
add_custom_command(
TARGET "${executable_target}"
POST_BUILD
@@ -759,15 +779,13 @@ function(swift_benchmark_compile)
add_custom_target("check-${executable_target}"
COMMAND "${swift-bin-dir}/Benchmark_Driver" "run"
"-o" "O" "--output-dir" "${CMAKE_CURRENT_BINARY_DIR}/logs"
"--architecture" "${arch}"
"--swift-repo" "${SWIFT_SOURCE_DIR}"
"--independent-samples" "${SWIFT_BENCHMARK_NUM_O_ITERATIONS}"
"-o" "O"
${SWIFT_BENCHMARK_ARGS}
${SWIFT_O_BENCHMARK_ARGS}
COMMAND "${swift-bin-dir}/Benchmark_Driver" "run"
"-o" "Onone" "--output-dir" "${CMAKE_CURRENT_BINARY_DIR}/logs"
"--swift-repo" "${SWIFT_SOURCE_DIR}"
"--architecture" "${arch}"
"--independent-samples" "${SWIFT_BENCHMARK_NUM_ONONE_ITERATIONS}"
"-o" "Onone"
${SWIFT_BENCHMARK_ARGS}
${SWIFT_ONONE_BENCHMARK_ARGS}
COMMAND "${swift-bin-dir}/Benchmark_Driver" "compare"
"--log-dir" "${CMAKE_CURRENT_BINARY_DIR}/logs"
"--swift-repo" "${SWIFT_SOURCE_DIR}"

View File

@@ -226,6 +226,8 @@ class BenchmarkDriver(object):
cmd.extend([str(self.test_number.get(name, name)) for name in self.tests])
if num_samples > 0:
cmd.append("--num-samples={0}".format(num_samples))
else:
cmd.append("--min-samples=2")
if num_iters > 0:
cmd.append("--num-iters={0}".format(num_iters))
if sample_time > 0: