Skip to content

Commit

Permalink
Add some more benchmarking.
Browse files Browse the repository at this point in the history
  • Loading branch information
tmadden committed Sep 4, 2020
1 parent 1d8048a commit d566b56
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions unit_tests/signals/state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,31 @@ TEST_CASE("state changes and component dirtying", "[signals][state]")
refresh_system(sys);

REQUIRE(log.str() == "clean;12;clean;12;writing;dirty;13;clean;13;");

// And some benchmarking...
BENCHMARK("deep state changes")
{
refresh_system(sys);

my_state_change_event e;
dispatch_event(sys, e);
};
}

TEST_CASE("get_state benchmarks", "[signals][state]")
{
BENCHMARK("get_state")
{
alia::system sys;
initialize_system(sys, [&](context ctx) {
scoped_component_container srr(ctx);
// The get_state call is all we really want to benchmark, but
// somehow, invoking the BENCHMARK macro inside component code
// causes a stack overflow, so we just repeat it many times so that
// it dominates the results.
for (int i = 0; i != 20; ++i)
get_state(ctx, 12);
});
refresh_system(sys);
};
}

0 comments on commit d566b56

Please sign in to comment.