Profiler refine (#23294)

* refine output of profiler for child event
revert-23830-2.0-beta
wangchaochaohu 5 years ago committed by GitHub
parent a7b0ff33ce
commit 1ee2a9a424
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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,
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,
<< 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,
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

Loading…
Cancel
Save