MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / print_node

Method print_node

src/core/impl/utils/stats.cpp:32–69  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30}
31
32std::pair<long, long> Stats::print_node(
33 std::string name, TimerNode& node, size_t indent) {
34 auto print_indent = [&] {
35 for (size_t i = 0; i < indent; ++i) {
36 printf(" ");
37 }
38 };
39 long ns = 0, count = 0;
40 if (auto& timer = node.timer) {
41 print_indent();
42 printf("%s costs %'ld ns, hits %'ld times\n", name.c_str(),
43 (long)timer->get().count(), (long)timer->count());
44 ns = timer->get().count();
45 count = timer->count();
46 }
47 if (!node.children.empty()) {
48 bool collect_children = node.timer == nullptr;
49 if (collect_children) {
50 print_indent();
51 printf("%s:\n", name.c_str());
52 }
53 long ns = 0, count = 0;
54 for (auto&& child : node.children) {
55 auto&& child_res = print_node(child.first, *child.second, indent + 4);
56 auto&& child_ns = child_res.first;
57 auto&& child_count = child_res.second;
58 if (collect_children) {
59 ns += child_ns;
60 count += child_count;
61 }
62 }
63 if (collect_children) {
64 print_indent();
65 printf("total costs %'ld ns, hits %'ld times\n", ns, count);
66 }
67 }
68 return {ns, count};
69}
70
71void Stats::print() {
72 for (auto&& child : sm_root.children) {

Callers

nothing calls this directly

Calls 3

countMethod · 0.45
getMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected