Commit 75ccf0c3 authored by Pádraig Ó Conbhuí's avatar Pádraig Ó Conbhuí
Browse files

Add background and some comments, minor tweaks

parent 62288754
Pipeline #2544 passed with stages
in 3 minutes and 14 seconds
......@@ -77,7 +77,8 @@ bool do_something() {
// Measure the total time spent in the loop, and gather the time per
// iteration
auto loop_trace = PERFORATE_SCOPED_TRACE_V("do_something::loop").call_count(0);
auto loop_trace =
PERFORATE_MAKE_SCOPED_TRACE("do_something::loop").call_count(0);
// Just some busy work that won't get optimized away...
std::vector<int> v;
......@@ -90,7 +91,7 @@ bool do_something() {
}
// end the scope of loop_trace early, before the end of the block
perforate::end_scoped_trace(std::move(loop_trace));
PERFORATE_END_SCOPED_TRACE(std::move(loop_trace));
const int acc = std::accumulate(v.cbegin(), v.cend(), int(0));
......
This diff is collapsed.
......@@ -22,6 +22,8 @@ public:
type index;
template <typename Tag> type make() { return ++index; }
template <typename Tag> type access(type i) { return i; }
};
class type_index : public perforate::detail::per_tag<index_policy> {};
......@@ -309,16 +311,16 @@ TEST_CASE("scoped_trace helper functions and macros", "[scoped_trace]") {
REQUIRE(stats.call_count() == num_calls);
}
SECTION("PERFORATE_SCOPED_TRACE_V should return a scoped_trace") {
SECTION("PERFORATE_MAKE_SCOPED_TRACE should return a scoped_trace") {
const int64_t num_calls = 33;
for (int64_t i = 0; i < num_calls; i++) {
auto mst = PERFORATE_SCOPED_TRACE_V("test::macro_scoped_trace_v");
auto mst = PERFORATE_MAKE_SCOPED_TRACE("test::macro_scoped_trace_v");
const auto &stats = find_stats("test::macro_scoped_trace_v");
REQUIRE(stats.call_count() == i);
end_scoped_trace(std::move(mst));
PERFORATE_END_SCOPED_TRACE(std::move(mst));
REQUIRE(stats.call_count() == i + 1);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment