Skip to content

Commit

Permalink
test result accumulation
Browse files Browse the repository at this point in the history
  • Loading branch information
upsj committed Feb 16, 2025
1 parent 10f9a0a commit eca15d0
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 5 deletions.
1 change: 1 addition & 0 deletions core/log/profiler_hook_summary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@ ProfilerHook::nested_summary_entry build_tree(const nested_summary& summary)
entry.name = summary.names[summary_node.name_id];
entry.elapsed = summary_node.elapsed;
entry.count = summary_node.count;
entry.work_estimate = summary_node.work_estimate;
const auto child_range = child_ranges[summary_node.node_id];
for (auto i = child_range.first; i < child_range.second; i++) {
entry.children.emplace_back();
Expand Down
40 changes: 35 additions & 5 deletions core/test/log/profiler_hook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,11 @@ void call_ranges_unique(std::shared_ptr<gko::log::ProfilerHook> logger)
}
}
auto range6 = logger->user_range("bazzzz");
// an operation that requires accumulation of work estimates
logger->on_copy_started(nullptr, nullptr, 0, 0, 10);
logger->on_copy_completed(nullptr, nullptr, 0, 0, 10);
logger->on_copy_started(nullptr, nullptr, 0, 0, 35);
logger->on_copy_completed(nullptr, nullptr, 0, 0, 35);
}

struct TestSummaryWriter : gko::log::ProfilerHook::SummaryWriter {
Expand All @@ -291,11 +296,14 @@ struct TestSummaryWriter : gko::log::ProfilerHook::SummaryWriter {
* bazz()
* bazzz()
* )
* bazzzz()
* bazzzz(
* copy()
* copy()
* )
* )
* )
*/
ASSERT_EQ(e.size(), 7);
ASSERT_EQ(e.size(), 8);
ASSERT_EQ(e[0].name, "total");
ASSERT_EQ(e[0].count, 1);
ASSERT_EQ(e[1].name, "foo");
Expand All @@ -310,6 +318,8 @@ struct TestSummaryWriter : gko::log::ProfilerHook::SummaryWriter {
ASSERT_EQ(e[5].count, 1);
ASSERT_EQ(e[6].name, "bazzzz");
ASSERT_EQ(e[6].count, 1);
ASSERT_EQ(e[7].name, "copy");
ASSERT_EQ(e[7].count, 2);
ASSERT_EQ(e[0].inclusive, e[0].exclusive + e[1].inclusive);
ASSERT_EQ(e[1].inclusive, e[1].exclusive + e[2].inclusive +
e[3].inclusive + e[6].inclusive);
Expand All @@ -318,7 +328,12 @@ struct TestSummaryWriter : gko::log::ProfilerHook::SummaryWriter {
e[3].exclusive + e[4].inclusive + e[5].inclusive);
ASSERT_EQ(e[4].inclusive, e[4].exclusive);
ASSERT_EQ(e[5].inclusive, e[5].exclusive);
ASSERT_EQ(e[6].inclusive, e[6].exclusive);
ASSERT_EQ(e[6].inclusive, e[6].exclusive + e[7].inclusive);
ASSERT_EQ(e[7].inclusive, e[7].exclusive);
const auto work_estimate = std::get<gko::memory_bound_work_estimate>(
e[7].work_estimate.value());
ASSERT_EQ(work_estimate.bytes_read, 45);
ASSERT_EQ(work_estimate.bytes_written, 45);
}
};

Expand Down Expand Up @@ -353,6 +368,11 @@ void call_ranges(std::shared_ptr<gko::log::ProfilerHook> logger)
}
}
auto range6 = logger->user_range("baz");
// an operation that requires accumulation of work estimates
logger->on_copy_started(nullptr, nullptr, 0, 0, 10);
logger->on_copy_completed(nullptr, nullptr, 0, 0, 10);
logger->on_copy_started(nullptr, nullptr, 0, 0, 35);
logger->on_copy_completed(nullptr, nullptr, 0, 0, 35);
}


Expand All @@ -369,7 +389,10 @@ struct TestNestedSummaryWriter : gko::log::ProfilerHook::NestedSummaryWriter {
* baz()
* bazz()
* )
* baz()
* baz(
* copy()
* copy()
* )
* )
* )
*/
Expand All @@ -388,12 +411,19 @@ struct TestNestedSummaryWriter : gko::log::ProfilerHook::NestedSummaryWriter {
ASSERT_EQ(f.children[1].children.size(), 2);
ASSERT_EQ(f.children[2].name, "baz");
ASSERT_EQ(f.children[2].count, 1);
ASSERT_EQ(f.children[2].children.size(), 0);
ASSERT_EQ(f.children[2].children.size(), 1);
auto& b = f.children[1];
ASSERT_EQ(b.children[0].name, "baz");
ASSERT_EQ(b.children[0].count, 1);
ASSERT_EQ(b.children[1].name, "bazz");
ASSERT_EQ(b.children[1].count, 1);
auto& bb = f.children[2];
ASSERT_EQ(bb.children[0].name, "copy");
ASSERT_EQ(bb.children[0].count, 2);
const auto work_estimate = std::get<gko::memory_bound_work_estimate>(
bb.children[0].work_estimate.value());
ASSERT_EQ(work_estimate.bytes_read, 45);
ASSERT_EQ(work_estimate.bytes_written, 45);
}
};

Expand Down

0 comments on commit eca15d0

Please sign in to comment.