cb66c5d68e
bazel / bazel.ubuntu-latest (push) Failing after 1s
build-and-test-perfcounters / ubuntu-latest.Debug (push) Failing after 0s
build-and-test-perfcounters / ubuntu-latest.Release (push) Failing after 1s
doxygen / Build HTML documentation (push) Failing after 1s
python + Bazel pre-commit checks / pre-commit (push) Failing after 1s
sanitizer / tsan.Debug (push) Failing after 1s
sanitizer / ubsan.Debug (push) Failing after 0s
sanitizer / ubsan.RelWithDebInfo (push) Failing after 1s
build-and-test-min-cmake / ubuntu-latest.min-cmake (push) Failing after 1s
clang-format-lint / check-clang-format (push) Failing after 1s
sanitizer / asan.Debug (push) Failing after 1s
sanitizer / msan.RelWithDebInfo (push) Failing after 1s
clang-tidy / run-clang-tidy (push) Failing after 1s
sanitizer / msan.Debug (push) Failing after 1s
sanitizer / asan.RelWithDebInfo (push) Failing after 0s
sanitizer / tsan.RelWithDebInfo (push) Failing after 0s
test-bindings / Test Rust bindings on ubuntu-latest (push) Failing after 0s
test-bindings / Test Python 3.10 bindings on ubuntu-latest (push) Failing after 0s
test-bindings / Test Python 3.11 bindings on ubuntu-latest (push) Failing after 0s
test-bindings / Test Python 3.12 bindings on ubuntu-latest (push) Failing after 1s
test-bindings / Test Python 3.13 bindings on ubuntu-latest (push) Failing after 0s
build-and-test / macos-latest.Debug.shared.clang++ (push) Has been cancelled
build-and-test / ubuntu-22.04.Debug.shared.clang++ (push) Has been cancelled
build-and-test / ubuntu-24.04.Debug.shared.clang++ (push) Has been cancelled
build-and-test / ubuntu-24.04-arm.Debug.shared.clang++ (push) Has been cancelled
bazel / bazel.macos-latest (push) Has been cancelled
bazel / bazel.windows-latest (push) Has been cancelled
build-and-test-min-cmake / macos-latest.min-cmake (push) Has been cancelled
build-and-test / ubuntu-22.04.Debug.static.clang++ (push) Has been cancelled
build-and-test / macos-latest.Debug.shared.g++ (push) Has been cancelled
build-and-test / ubuntu-22.04.Debug.shared.g++ (push) Has been cancelled
build-and-test / ubuntu-24.04.Debug.shared.g++ (push) Has been cancelled
build-and-test / ubuntu-24.04-arm.Debug.shared.g++ (push) Has been cancelled
build-and-test / macos-latest.Debug.static.g++ (push) Has been cancelled
build-and-test / ubuntu-22.04.Debug.static.g++ (push) Has been cancelled
build-and-test / ubuntu-24.04.Debug.static.g++ (push) Has been cancelled
build-and-test / ubuntu-24.04-arm.Debug.static.g++ (push) Has been cancelled
build-and-test / macos-latest.Release.shared.clang++ (push) Has been cancelled
build-and-test / ubuntu-22.04.Release.shared.clang++ (push) Has been cancelled
build-and-test / ubuntu-24.04.Release.shared.clang++ (push) Has been cancelled
build-and-test / ubuntu-24.04-arm.Release.shared.clang++ (push) Has been cancelled
build-and-test / macos-latest.Release.static.clang++ (push) Has been cancelled
build-and-test / ubuntu-22.04.Release.static.clang++ (push) Has been cancelled
build-and-test / macos-latest.Debug.static.clang++ (push) Has been cancelled
build-and-test / ubuntu-24.04.Debug.static.clang++ (push) Has been cancelled
build-and-test / ubuntu-24.04-arm.Debug.static.clang++ (push) Has been cancelled
build-and-test / macos-latest.Release.static.g++ (push) Has been cancelled
build-and-test / ubuntu-22.04.Release.static.g++ (push) Has been cancelled
build-and-test / windows-2025.Debug.static.VS-18-2025 (push) Has been cancelled
build-and-test / windows-2022.Release.shared.VS-17-2022 (push) Has been cancelled
build-and-test / windows-2022.Release.static.VS-17-2022 (push) Has been cancelled
build-and-test / windows-2025.Release.shared.VS-18-2025 (push) Has been cancelled
build-and-test / windows-2025.Release.static.VS-18-2025 (push) Has been cancelled
build-and-test / windows-latest.Debug.shared.CLANG64 (push) Has been cancelled
build-and-test / windows-latest.Debug.shared.MINGW64 (push) Has been cancelled
build-and-test / windows-latest.Debug.shared.UCRT64 (push) Has been cancelled
build-and-test / windows-latest.Debug.static.CLANG64 (push) Has been cancelled
build-and-test / windows-latest.Debug.static.MINGW64 (push) Has been cancelled
build-and-test / windows-latest.Debug.static.UCRT64 (push) Has been cancelled
build-and-test / ubuntu-24.04.Release.static.clang++ (push) Has been cancelled
build-and-test / ubuntu-24.04-arm.Release.static.clang++ (push) Has been cancelled
build-and-test / macos-latest.Release.shared.g++ (push) Has been cancelled
build-and-test / ubuntu-22.04.Release.shared.g++ (push) Has been cancelled
build-and-test / ubuntu-24.04.Release.shared.g++ (push) Has been cancelled
build-and-test / ubuntu-24.04-arm.Release.shared.g++ (push) Has been cancelled
build-and-test / ubuntu-24.04.Release.static.g++ (push) Has been cancelled
build-and-test / ubuntu-24.04-arm.Release.static.g++ (push) Has been cancelled
build-and-test / windows-2022.Debug.shared.VS-17-2022 (push) Has been cancelled
build-and-test / windows-2022.Debug.static.VS-17-2022 (push) Has been cancelled
build-and-test / windows-2025.Debug.shared.VS-18-2025 (push) Has been cancelled
build-and-test / windows-latest.Release.static.MINGW64 (push) Has been cancelled
build-and-test / windows-latest.Release.static.UCRT64 (push) Has been cancelled
test-bindings / Test Python 3.10 bindings on macos-latest (push) Has been cancelled
test-bindings / Test Python 3.11 bindings on macos-latest (push) Has been cancelled
test-bindings / Test Python 3.12 bindings on macos-latest (push) Has been cancelled
test-bindings / Test Python 3.13 bindings on macos-latest (push) Has been cancelled
build-and-test / windows-latest.Release.shared.CLANG64 (push) Has been cancelled
build-and-test / windows-latest.Release.shared.MINGW64 (push) Has been cancelled
build-and-test / windows-latest.Release.shared.UCRT64 (push) Has been cancelled
build-and-test / windows-latest.Release.static.CLANG64 (push) Has been cancelled
test-bindings / Test Python 3.12 bindings on windows-latest (push) Has been cancelled
test-bindings / Test Python 3.13 bindings on windows-latest (push) Has been cancelled
test-bindings / Test Python 3.10 bindings on windows-latest (push) Has been cancelled
test-bindings / Test Python 3.11 bindings on windows-latest (push) Has been cancelled
test-bindings / Test Rust bindings on macos-latest (push) Has been cancelled
test-bindings / Test Rust bindings on windows-latest (push) Has been cancelled
259 lines
13 KiB
C++
259 lines
13 KiB
C++
|
|
#include "benchmark/benchmark_api.h"
|
|
#include "benchmark/registration.h"
|
|
#include "benchmark/state.h"
|
|
#include "output_test.h"
|
|
|
|
namespace {
|
|
// ========================================================================= //
|
|
// ------------------------ Testing Basic Output --------------------------- //
|
|
// ========================================================================= //
|
|
|
|
void BM_ExplicitRepetitions(benchmark::State& state) {
|
|
for (auto _ : state) {
|
|
}
|
|
}
|
|
BENCHMARK(BM_ExplicitRepetitions)->Repetitions(2);
|
|
|
|
ADD_CASES(TC_ConsoleOut,
|
|
{{"^BM_ExplicitRepetitions/repeats:2 %console_report$"}});
|
|
ADD_CASES(TC_ConsoleOut,
|
|
{{"^BM_ExplicitRepetitions/repeats:2 %console_report$"}});
|
|
ADD_CASES(TC_ConsoleOut,
|
|
{{"^BM_ExplicitRepetitions/repeats:2_mean %console_report$"}});
|
|
ADD_CASES(TC_ConsoleOut,
|
|
{{"^BM_ExplicitRepetitions/repeats:2_median %console_report$"}});
|
|
ADD_CASES(TC_ConsoleOut,
|
|
{{"^BM_ExplicitRepetitions/repeats:2_stddev %console_report$"}});
|
|
ADD_CASES(TC_JSONOut,
|
|
{{"\"name\": \"BM_ExplicitRepetitions/repeats:2\",$"},
|
|
{"\"family_index\": 0,$", MR_Next},
|
|
{"\"per_family_instance_index\": 0,$", MR_Next},
|
|
{"\"run_name\": \"BM_ExplicitRepetitions/repeats:2\",$", MR_Next},
|
|
{"\"run_type\": \"iteration\",$", MR_Next},
|
|
{"\"repetitions\": 2,$", MR_Next},
|
|
{"\"repetition_index\": 0,$", MR_Next},
|
|
{"\"threads\": 1,$", MR_Next},
|
|
{"\"iterations\": %int,$", MR_Next},
|
|
{"\"real_time\": %float,$", MR_Next},
|
|
{"\"cpu_time\": %float,$", MR_Next},
|
|
{"\"time_unit\": \"ns\"$", MR_Next},
|
|
{"}", MR_Next}});
|
|
ADD_CASES(TC_JSONOut,
|
|
{{"\"name\": \"BM_ExplicitRepetitions/repeats:2\",$"},
|
|
{"\"family_index\": 0,$", MR_Next},
|
|
{"\"per_family_instance_index\": 0,$", MR_Next},
|
|
{"\"run_name\": \"BM_ExplicitRepetitions/repeats:2\",$", MR_Next},
|
|
{"\"run_type\": \"iteration\",$", MR_Next},
|
|
{"\"repetitions\": 2,$", MR_Next},
|
|
{"\"repetition_index\": 1,$", MR_Next},
|
|
{"\"threads\": 1,$", MR_Next},
|
|
{"\"iterations\": %int,$", MR_Next},
|
|
{"\"real_time\": %float,$", MR_Next},
|
|
{"\"cpu_time\": %float,$", MR_Next},
|
|
{"\"time_unit\": \"ns\"$", MR_Next},
|
|
{"}", MR_Next}});
|
|
ADD_CASES(TC_JSONOut,
|
|
{{"\"name\": \"BM_ExplicitRepetitions/repeats:2_mean\",$"},
|
|
{"\"family_index\": 0,$", MR_Next},
|
|
{"\"per_family_instance_index\": 0,$", MR_Next},
|
|
{"\"run_name\": \"BM_ExplicitRepetitions/repeats:2\",$", MR_Next},
|
|
{"\"run_type\": \"aggregate\",$", MR_Next},
|
|
{"\"repetitions\": 2,$", MR_Next},
|
|
{"\"threads\": 1,$", MR_Next},
|
|
{"\"aggregate_name\": \"mean\",$", MR_Next},
|
|
{"\"aggregate_unit\": \"time\",$", MR_Next},
|
|
{"\"iterations\": %int,$", MR_Next},
|
|
{"\"real_time\": %float,$", MR_Next},
|
|
{"\"cpu_time\": %float,$", MR_Next},
|
|
{"\"time_unit\": \"ns\"$", MR_Next},
|
|
{"}", MR_Next}});
|
|
ADD_CASES(TC_JSONOut,
|
|
{{"\"name\": \"BM_ExplicitRepetitions/repeats:2_median\",$"},
|
|
{"\"family_index\": 0,$", MR_Next},
|
|
{"\"per_family_instance_index\": 0,$", MR_Next},
|
|
{"\"run_name\": \"BM_ExplicitRepetitions/repeats:2\",$", MR_Next},
|
|
{"\"run_type\": \"aggregate\",$", MR_Next},
|
|
{"\"repetitions\": 2,$", MR_Next},
|
|
{"\"threads\": 1,$", MR_Next},
|
|
{"\"aggregate_name\": \"median\",$", MR_Next},
|
|
{"\"aggregate_unit\": \"time\",$", MR_Next},
|
|
{"\"iterations\": %int,$", MR_Next},
|
|
{"\"real_time\": %float,$", MR_Next},
|
|
{"\"cpu_time\": %float,$", MR_Next},
|
|
{"\"time_unit\": \"ns\"$", MR_Next},
|
|
{"}", MR_Next}});
|
|
ADD_CASES(TC_JSONOut,
|
|
{{"\"name\": \"BM_ExplicitRepetitions/repeats:2_stddev\",$"},
|
|
{"\"family_index\": 0,$", MR_Next},
|
|
{"\"per_family_instance_index\": 0,$", MR_Next},
|
|
{"\"run_name\": \"BM_ExplicitRepetitions/repeats:2\",$", MR_Next},
|
|
{"\"run_type\": \"aggregate\",$", MR_Next},
|
|
{"\"repetitions\": 2,$", MR_Next},
|
|
{"\"threads\": 1,$", MR_Next},
|
|
{"\"aggregate_name\": \"stddev\",$", MR_Next},
|
|
{"\"aggregate_unit\": \"time\",$", MR_Next},
|
|
{"\"iterations\": %int,$", MR_Next},
|
|
{"\"real_time\": %float,$", MR_Next},
|
|
{"\"cpu_time\": %float,$", MR_Next},
|
|
{"\"time_unit\": \"ns\"$", MR_Next},
|
|
{"}", MR_Next}});
|
|
ADD_CASES(TC_CSVOut, {{"^\"BM_ExplicitRepetitions/repeats:2\",%csv_report$"}});
|
|
ADD_CASES(TC_CSVOut, {{"^\"BM_ExplicitRepetitions/repeats:2\",%csv_report$"}});
|
|
ADD_CASES(TC_CSVOut,
|
|
{{"^\"BM_ExplicitRepetitions/repeats:2_mean\",%csv_report$"}});
|
|
ADD_CASES(TC_CSVOut,
|
|
{{"^\"BM_ExplicitRepetitions/repeats:2_median\",%csv_report$"}});
|
|
ADD_CASES(TC_CSVOut,
|
|
{{"^\"BM_ExplicitRepetitions/repeats:2_stddev\",%csv_report$"}});
|
|
|
|
// ========================================================================= //
|
|
// ------------------------ Testing Basic Output --------------------------- //
|
|
// ========================================================================= //
|
|
|
|
void BM_ImplicitRepetitions(benchmark::State& state) {
|
|
for (auto _ : state) {
|
|
}
|
|
}
|
|
BENCHMARK(BM_ImplicitRepetitions);
|
|
|
|
ADD_CASES(TC_ConsoleOut, {{"^BM_ImplicitRepetitions %console_report$"}});
|
|
ADD_CASES(TC_ConsoleOut, {{"^BM_ImplicitRepetitions %console_report$"}});
|
|
ADD_CASES(TC_ConsoleOut, {{"^BM_ImplicitRepetitions %console_report$"}});
|
|
ADD_CASES(TC_ConsoleOut, {{"^BM_ImplicitRepetitions_mean %console_report$"}});
|
|
ADD_CASES(TC_ConsoleOut, {{"^BM_ImplicitRepetitions_median %console_report$"}});
|
|
ADD_CASES(TC_ConsoleOut, {{"^BM_ImplicitRepetitions_stddev %console_report$"}});
|
|
ADD_CASES(TC_JSONOut, {{"\"name\": \"BM_ImplicitRepetitions\",$"},
|
|
{"\"family_index\": 1,$", MR_Next},
|
|
{"\"per_family_instance_index\": 0,$", MR_Next},
|
|
{"\"run_name\": \"BM_ImplicitRepetitions\",$", MR_Next},
|
|
{"\"run_type\": \"iteration\",$", MR_Next},
|
|
{"\"repetitions\": 3,$", MR_Next},
|
|
{"\"repetition_index\": 0,$", MR_Next},
|
|
{"\"threads\": 1,$", MR_Next},
|
|
{"\"iterations\": %int,$", MR_Next},
|
|
{"\"real_time\": %float,$", MR_Next},
|
|
{"\"cpu_time\": %float,$", MR_Next},
|
|
{"\"time_unit\": \"ns\"$", MR_Next},
|
|
{"}", MR_Next}});
|
|
ADD_CASES(TC_JSONOut, {{"\"name\": \"BM_ImplicitRepetitions\",$"},
|
|
{"\"family_index\": 1,$", MR_Next},
|
|
{"\"per_family_instance_index\": 0,$", MR_Next},
|
|
{"\"run_name\": \"BM_ImplicitRepetitions\",$", MR_Next},
|
|
{"\"run_type\": \"iteration\",$", MR_Next},
|
|
{"\"repetitions\": 3,$", MR_Next},
|
|
{"\"repetition_index\": 1,$", MR_Next},
|
|
{"\"threads\": 1,$", MR_Next},
|
|
{"\"iterations\": %int,$", MR_Next},
|
|
{"\"real_time\": %float,$", MR_Next},
|
|
{"\"cpu_time\": %float,$", MR_Next},
|
|
{"\"time_unit\": \"ns\"$", MR_Next},
|
|
{"}", MR_Next}});
|
|
ADD_CASES(TC_JSONOut, {{"\"name\": \"BM_ImplicitRepetitions\",$"},
|
|
{"\"family_index\": 1,$", MR_Next},
|
|
{"\"per_family_instance_index\": 0,$", MR_Next},
|
|
{"\"run_name\": \"BM_ImplicitRepetitions\",$", MR_Next},
|
|
{"\"run_type\": \"iteration\",$", MR_Next},
|
|
{"\"repetitions\": 3,$", MR_Next},
|
|
{"\"repetition_index\": 2,$", MR_Next},
|
|
{"\"threads\": 1,$", MR_Next},
|
|
{"\"iterations\": %int,$", MR_Next},
|
|
{"\"real_time\": %float,$", MR_Next},
|
|
{"\"cpu_time\": %float,$", MR_Next},
|
|
{"\"time_unit\": \"ns\"$", MR_Next},
|
|
{"}", MR_Next}});
|
|
ADD_CASES(TC_JSONOut, {{"\"name\": \"BM_ImplicitRepetitions_mean\",$"},
|
|
{"\"family_index\": 1,$", MR_Next},
|
|
{"\"per_family_instance_index\": 0,$", MR_Next},
|
|
{"\"run_name\": \"BM_ImplicitRepetitions\",$", MR_Next},
|
|
{"\"run_type\": \"aggregate\",$", MR_Next},
|
|
{"\"repetitions\": 3,$", MR_Next},
|
|
{"\"threads\": 1,$", MR_Next},
|
|
{"\"aggregate_name\": \"mean\",$", MR_Next},
|
|
{"\"aggregate_unit\": \"time\",$", MR_Next},
|
|
{"\"iterations\": %int,$", MR_Next},
|
|
{"\"real_time\": %float,$", MR_Next},
|
|
{"\"cpu_time\": %float,$", MR_Next},
|
|
{"\"time_unit\": \"ns\"$", MR_Next},
|
|
{"}", MR_Next}});
|
|
ADD_CASES(TC_JSONOut, {{"\"name\": \"BM_ImplicitRepetitions_median\",$"},
|
|
{"\"family_index\": 1,$", MR_Next},
|
|
{"\"per_family_instance_index\": 0,$", MR_Next},
|
|
{"\"run_name\": \"BM_ImplicitRepetitions\",$", MR_Next},
|
|
{"\"run_type\": \"aggregate\",$", MR_Next},
|
|
{"\"repetitions\": 3,$", MR_Next},
|
|
{"\"threads\": 1,$", MR_Next},
|
|
{"\"aggregate_name\": \"median\",$", MR_Next},
|
|
{"\"aggregate_unit\": \"time\",$", MR_Next},
|
|
{"\"iterations\": %int,$", MR_Next},
|
|
{"\"real_time\": %float,$", MR_Next},
|
|
{"\"cpu_time\": %float,$", MR_Next},
|
|
{"\"time_unit\": \"ns\"$", MR_Next},
|
|
{"}", MR_Next}});
|
|
ADD_CASES(TC_JSONOut, {{"\"name\": \"BM_ImplicitRepetitions_stddev\",$"},
|
|
{"\"family_index\": 1,$", MR_Next},
|
|
{"\"per_family_instance_index\": 0,$", MR_Next},
|
|
{"\"run_name\": \"BM_ImplicitRepetitions\",$", MR_Next},
|
|
{"\"run_type\": \"aggregate\",$", MR_Next},
|
|
{"\"repetitions\": 3,$", MR_Next},
|
|
{"\"threads\": 1,$", MR_Next},
|
|
{"\"aggregate_name\": \"stddev\",$", MR_Next},
|
|
{"\"aggregate_unit\": \"time\",$", MR_Next},
|
|
{"\"iterations\": %int,$", MR_Next},
|
|
{"\"real_time\": %float,$", MR_Next},
|
|
{"\"cpu_time\": %float,$", MR_Next},
|
|
{"\"time_unit\": \"ns\"$", MR_Next},
|
|
{"}", MR_Next}});
|
|
ADD_CASES(TC_CSVOut, {{"^\"BM_ImplicitRepetitions\",%csv_report$"}});
|
|
ADD_CASES(TC_CSVOut, {{"^\"BM_ImplicitRepetitions\",%csv_report$"}});
|
|
ADD_CASES(TC_CSVOut, {{"^\"BM_ImplicitRepetitions_mean\",%csv_report$"}});
|
|
ADD_CASES(TC_CSVOut, {{"^\"BM_ImplicitRepetitions_median\",%csv_report$"}});
|
|
ADD_CASES(TC_CSVOut, {{"^\"BM_ImplicitRepetitions_stddev\",%csv_report$"}});
|
|
|
|
// ========================================================================= //
|
|
// --------------------- Testing Skipped Repetitions ------------------------ //
|
|
// ========================================================================= //
|
|
|
|
void BM_SkippedFirstRepetition(benchmark::State& state) {
|
|
static int repetition_index = 0;
|
|
if (repetition_index++ == 0) {
|
|
state.SkipWithError("skipped first repetition");
|
|
return;
|
|
}
|
|
for (auto _ : state) {
|
|
}
|
|
}
|
|
BENCHMARK(BM_SkippedFirstRepetition)->Repetitions(3);
|
|
|
|
ADD_CASES(
|
|
TC_ConsoleOut,
|
|
{{"^BM_SkippedFirstRepetition/repeats:3[ ]+ERROR OCCURRED: "
|
|
"'skipped first repetition'$"},
|
|
{"^BM_SkippedFirstRepetition/repeats:3 %console_report$", MR_Next},
|
|
{"^BM_SkippedFirstRepetition/repeats:3 %console_report$", MR_Next},
|
|
{"^BM_SkippedFirstRepetition/repeats:3_mean %console_report$", MR_Next},
|
|
{"^BM_SkippedFirstRepetition/repeats:3_median %console_report$", MR_Next},
|
|
{"^BM_SkippedFirstRepetition/repeats:3_stddev %console_report$",
|
|
MR_Next}});
|
|
ADD_CASES(TC_JSONOut,
|
|
{{"\"name\": \"BM_SkippedFirstRepetition/repeats:3_mean\",$"},
|
|
{"\"run_type\": \"aggregate\",$"},
|
|
{"\"repetitions\": 3,$", MR_Next},
|
|
{"\"threads\": 1,$", MR_Next},
|
|
{"\"aggregate_name\": \"mean\",$", MR_Next},
|
|
{"\"aggregate_unit\": \"time\",$", MR_Next},
|
|
{"\"iterations\": 2,$", MR_Next}});
|
|
ADD_CASES(TC_CSVOut,
|
|
{{"^\"BM_SkippedFirstRepetition/repeats:3_mean\",2,%float,%float,"
|
|
"ns,,,,,$"}});
|
|
} // end namespace
|
|
|
|
// ========================================================================= //
|
|
// --------------------------- TEST CASES END ------------------------------ //
|
|
// ========================================================================= //
|
|
|
|
int main(int argc, char* argv[]) {
|
|
benchmark::MaybeReenterWithoutASLR(argc, argv);
|
|
RunOutputTests(argc, argv);
|
|
}
|