Skip to content

Commit

Permalink
Fixes slic benchmarks in debug builds and reduces output verbosity
Browse files Browse the repository at this point in the history
  • Loading branch information
kennyweiss committed Nov 12, 2024
1 parent 2e38266 commit 4b89107
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/axom/slic/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ if (ENABLE_BENCHMARKS)

blt_add_benchmark(
NAME ${test_name}
COMMAND ${test_name} --benchmark_min_time=0.0001s )
COMMAND ${test_name} )
endforeach()
endif()

Expand Down
29 changes: 21 additions & 8 deletions src/axom/slic/tests/slic_benchmark_asserts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
#include "axom/slic/interface/slic.hpp"
#include "axom/slic/core/SimpleLogger.hpp"

#include <cstdint>
#include <iostream>

/*!
* \file
*
Expand All @@ -24,9 +27,9 @@ namespace
static constexpr bool IS_VALID = true;
static constexpr bool SHOULD_PRINT = false;

void printMsg(std::string const& str, bool override = false)
void printMsg(std::string const& str, bool always_print = false)
{
if(SHOULD_PRINT || override)
if(SHOULD_PRINT || always_print)
{
std::cout << str << std::endl;
}
Expand Down Expand Up @@ -168,11 +171,11 @@ static void BM_CallAssertDtorDuring(benchmark::State& state)

} // namespace

BENCHMARK(BM_AssertBefore);
BENCHMARK(BM_AssertAfter);
BENCHMARK(BM_CallAssertCtorBefore);
BENCHMARK(BM_CallAssertDtorBefore);
BENCHMARK(BM_CallAssertDtorDuring);
BENCHMARK(BM_AssertBefore)->Iterations(1);
BENCHMARK(BM_AssertAfter)->Iterations(1);
BENCHMARK(BM_CallAssertCtorBefore)->Iterations(1);
BENCHMARK(BM_CallAssertDtorBefore)->Iterations(1);
BENCHMARK(BM_CallAssertDtorDuring)->Iterations(1);

BENCHMARK_F(SetFixtureC, assertCtor)(benchmark::State& state)
{
Expand All @@ -182,6 +185,8 @@ BENCHMARK_F(SetFixtureC, assertCtor)(benchmark::State& state)
benchmark::DoNotOptimize(x);
}
}
BENCHMARK_REGISTER_F(SetFixtureC, assertCtor)->Iterations(1);

BENCHMARK_F(SetFixtureS, assertSetup)(benchmark::State& state)
{
while(state.KeepRunning())
Expand All @@ -190,6 +195,8 @@ BENCHMARK_F(SetFixtureS, assertSetup)(benchmark::State& state)
benchmark::DoNotOptimize(x);
}
}
BENCHMARK_REGISTER_F(SetFixtureS, assertSetup)->Iterations(1);

BENCHMARK_F(SetFixtureT, assertTeardown)(benchmark::State& state)
{
while(state.KeepRunning())
Expand All @@ -198,6 +205,8 @@ BENCHMARK_F(SetFixtureT, assertTeardown)(benchmark::State& state)
benchmark::DoNotOptimize(x);
}
}
BENCHMARK_REGISTER_F(SetFixtureT, assertTeardown)->Iterations(1);

BENCHMARK_F(SetFixtureD, assertDtor)(benchmark::State& state)
{
while(state.KeepRunning())
Expand All @@ -206,6 +215,7 @@ BENCHMARK_F(SetFixtureD, assertDtor)(benchmark::State& state)
benchmark::DoNotOptimize(x);
}
}
BENCHMARK_REGISTER_F(SetFixtureD, assertDtor)->Iterations(1);

// The following two benchmarks are here to show the order of construction,
// setup, teardown and destruction of benchmarks fixtures.
Expand All @@ -220,6 +230,8 @@ BENCHMARK_F(SetFixtureOutput, process1)(benchmark::State& state)
}
printMsg(" P1 (after)");
}
BENCHMARK_REGISTER_F(SetFixtureOutput, process1)->Iterations(1);

BENCHMARK_F(SetFixtureOutput, process2)(benchmark::State& state)
{
printMsg(" P2 (before)");
Expand All @@ -230,13 +242,14 @@ BENCHMARK_F(SetFixtureOutput, process2)(benchmark::State& state)
}
printMsg(" P2 (after)");
}
BENCHMARK_REGISTER_F(SetFixtureOutput, process2)->Iterations(1);

int main(int argc, char* argv[])
{
printMsg("at start of main");

printMsg(" Before init logger");
axom::slic::SimpleLogger logger; // create & initialize test logger,
axom::slic::SimpleLogger logger;
printMsg(" After init logger");

printMsg(" Before init benchmark");
Expand Down

0 comments on commit 4b89107

Please sign in to comment.