Skip to content

Commit 9ac9b8f

Browse files
committed
test result accumulation
1 parent d40f82a commit 9ac9b8f

File tree

2 files changed

+36
-5
lines changed

2 files changed

+36
-5
lines changed

core/log/profiler_hook_summary.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,7 @@ ProfilerHook::nested_summary_entry build_tree(const nested_summary& summary)
393393
entry.name = summary.names[summary_node.name_id];
394394
entry.elapsed = summary_node.elapsed;
395395
entry.count = summary_node.count;
396+
entry.work_estimate = summary_node.work_estimate;
396397
const auto child_range = child_ranges[summary_node.node_id];
397398
for (auto i = child_range.first; i < child_range.second; i++) {
398399
entry.children.emplace_back();

core/test/log/profiler_hook.cpp

+35-5
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,11 @@ void call_ranges_unique(std::shared_ptr<gko::log::ProfilerHook> logger)
276276
}
277277
}
278278
auto range6 = logger->user_range("bazzzz");
279+
// an operation that requires accumulation of work estimates
280+
logger->on_copy_started(nullptr, nullptr, 0, 0, 10);
281+
logger->on_copy_completed(nullptr, nullptr, 0, 0, 10);
282+
logger->on_copy_started(nullptr, nullptr, 0, 0, 35);
283+
logger->on_copy_completed(nullptr, nullptr, 0, 0, 35);
279284
}
280285

281286
struct TestSummaryWriter : gko::log::ProfilerHook::SummaryWriter {
@@ -291,11 +296,14 @@ struct TestSummaryWriter : gko::log::ProfilerHook::SummaryWriter {
291296
* bazz()
292297
* bazzz()
293298
* )
294-
* bazzzz()
299+
* bazzzz(
300+
* copy()
301+
* copy()
302+
* )
295303
* )
296304
* )
297305
*/
298-
ASSERT_EQ(e.size(), 7);
306+
ASSERT_EQ(e.size(), 8);
299307
ASSERT_EQ(e[0].name, "total");
300308
ASSERT_EQ(e[0].count, 1);
301309
ASSERT_EQ(e[1].name, "foo");
@@ -310,6 +318,8 @@ struct TestSummaryWriter : gko::log::ProfilerHook::SummaryWriter {
310318
ASSERT_EQ(e[5].count, 1);
311319
ASSERT_EQ(e[6].name, "bazzzz");
312320
ASSERT_EQ(e[6].count, 1);
321+
ASSERT_EQ(e[7].name, "copy");
322+
ASSERT_EQ(e[7].count, 2);
313323
ASSERT_EQ(e[0].inclusive, e[0].exclusive + e[1].inclusive);
314324
ASSERT_EQ(e[1].inclusive, e[1].exclusive + e[2].inclusive +
315325
e[3].inclusive + e[6].inclusive);
@@ -318,7 +328,12 @@ struct TestSummaryWriter : gko::log::ProfilerHook::SummaryWriter {
318328
e[3].exclusive + e[4].inclusive + e[5].inclusive);
319329
ASSERT_EQ(e[4].inclusive, e[4].exclusive);
320330
ASSERT_EQ(e[5].inclusive, e[5].exclusive);
321-
ASSERT_EQ(e[6].inclusive, e[6].exclusive);
331+
ASSERT_EQ(e[6].inclusive, e[6].exclusive + e[7].inclusive);
332+
ASSERT_EQ(e[7].inclusive, e[7].exclusive);
333+
const auto work_estimate = std::get<gko::memory_bound_work_estimate>(
334+
e[7].work_estimate.value());
335+
ASSERT_EQ(work_estimate.bytes_read, 45);
336+
ASSERT_EQ(work_estimate.bytes_written, 45);
322337
}
323338
};
324339

@@ -353,6 +368,11 @@ void call_ranges(std::shared_ptr<gko::log::ProfilerHook> logger)
353368
}
354369
}
355370
auto range6 = logger->user_range("baz");
371+
// an operation that requires accumulation of work estimates
372+
logger->on_copy_started(nullptr, nullptr, 0, 0, 10);
373+
logger->on_copy_completed(nullptr, nullptr, 0, 0, 10);
374+
logger->on_copy_started(nullptr, nullptr, 0, 0, 35);
375+
logger->on_copy_completed(nullptr, nullptr, 0, 0, 35);
356376
}
357377

358378

@@ -369,7 +389,10 @@ struct TestNestedSummaryWriter : gko::log::ProfilerHook::NestedSummaryWriter {
369389
* baz()
370390
* bazz()
371391
* )
372-
* baz()
392+
* baz(
393+
* copy()
394+
* copy()
395+
* )
373396
* )
374397
* )
375398
*/
@@ -388,12 +411,19 @@ struct TestNestedSummaryWriter : gko::log::ProfilerHook::NestedSummaryWriter {
388411
ASSERT_EQ(f.children[1].children.size(), 2);
389412
ASSERT_EQ(f.children[2].name, "baz");
390413
ASSERT_EQ(f.children[2].count, 1);
391-
ASSERT_EQ(f.children[2].children.size(), 0);
414+
ASSERT_EQ(f.children[2].children.size(), 1);
392415
auto& b = f.children[1];
393416
ASSERT_EQ(b.children[0].name, "baz");
394417
ASSERT_EQ(b.children[0].count, 1);
395418
ASSERT_EQ(b.children[1].name, "bazz");
396419
ASSERT_EQ(b.children[1].count, 1);
420+
auto& bb = f.children[2];
421+
ASSERT_EQ(bb.children[0].name, "copy");
422+
ASSERT_EQ(bb.children[0].count, 2);
423+
const auto work_estimate = std::get<gko::memory_bound_work_estimate>(
424+
bb.children[0].work_estimate.value());
425+
ASSERT_EQ(work_estimate.bytes_read, 45);
426+
ASSERT_EQ(work_estimate.bytes_written, 45);
397427
}
398428
};
399429

0 commit comments

Comments
 (0)