未验证 提交 1ee2a9a4 编写于 作者: W wangchaochaohu 提交者: GitHub

Profiler refine (#23294)

* refine output of profiler for child event 
上级 a7b0ff33
...@@ -493,11 +493,13 @@ void PrintOverHead(const OverHead &overhead, const size_t data_width) { ...@@ -493,11 +493,13 @@ void PrintOverHead(const OverHead &overhead, const size_t data_width) {
} }
// Print results // Print results
void PrintProfiler(const std::vector<std::vector<EventItem>> &events_table, void PrintProfiler(
const std::multimap<std::string, EventItem> &child_map, const std::vector<std::vector<EventItem>> &events_table,
const OverHead &overhead, const std::string &sorted_domain, const std::multimap<std::string, EventItem> &child_map,
const size_t name_width, const size_t data_width, std::function<bool(const EventItem &, const EventItem &)> sorted_func,
bool merge_thread, int print_depth) { EventSortingKey sorted_by, const OverHead &overhead,
const std::string &sorted_domain, const size_t name_width,
const size_t data_width, bool merge_thread, int print_depth) {
if (print_depth == 0) { if (print_depth == 0) {
// Output header information // Output header information
std::cout << "\n------------------------->" std::cout << "\n------------------------->"
...@@ -556,6 +558,10 @@ void PrintProfiler(const std::vector<std::vector<EventItem>> &events_table, ...@@ -556,6 +558,10 @@ void PrintProfiler(const std::vector<std::vector<EventItem>> &events_table,
table.push_back(it->second); table.push_back(it->second);
} }
} }
if (sorted_by != EventSortingKey::kDefault) {
std::sort(table.begin(), table.end(), sorted_func);
}
if (!table.empty()) child_table.push_back(table); if (!table.empty()) child_table.push_back(table);
auto name_len = event_item.name.length(); auto name_len = event_item.name.length();
...@@ -591,8 +597,9 @@ void PrintProfiler(const std::vector<std::vector<EventItem>> &events_table, ...@@ -591,8 +597,9 @@ void PrintProfiler(const std::vector<std::vector<EventItem>> &events_table,
<< std::setw(data_width) << event_item.ave_time << std::setw(data_width) << event_item.ave_time
<< std::setw(data_width) << event_item.ratio << std::endl; << std::setw(data_width) << event_item.ratio << std::endl;
PrintProfiler(child_table, child_map, overhead, sorted_domain, name_width, PrintProfiler(child_table, child_map, sorted_func, sorted_by, overhead,
data_width, merge_thread, print_depth + 1); sorted_domain, name_width, data_width, merge_thread,
print_depth + 1);
} }
} }
} }
...@@ -711,8 +718,8 @@ void ParseEvents(const std::vector<std::vector<Event>> &events, ...@@ -711,8 +718,8 @@ void ParseEvents(const std::vector<std::vector<Event>> &events,
sorted_by, &max_name_width, &overhead, merge_thread); sorted_by, &max_name_width, &overhead, merge_thread);
// Print report // Print report
PrintProfiler(events_table, child_map, overhead, sorted_domain, PrintProfiler(events_table, child_map, sorted_func, sorted_by, overhead,
max_name_width + 8, 12, merge_thread, 0); sorted_domain, max_name_width + 8, 12, merge_thread, 0);
} }
} // namespace platform } // namespace platform
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册