Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Profiler] Sort columns in table and csv output #9300

Merged
merged 1 commit into from
Oct 16, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/runtime/profiling.cc
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ String ShapeString(const std::vector<NDArray>& shapes) {

String ReportNode::AsCSV() const {
// get unique headers
std::unordered_set<std::string> unique_headers;
std::set<std::string> unique_headers;

for (auto row : calls) {
for (auto p : row) {
Expand Down Expand Up @@ -407,18 +407,19 @@ String ReportNode::AsTable(bool sort, bool aggregate) const {
}

// Table formatting
std::unordered_set<std::string> unique_headers;
std::set<std::string> unique_headers;

for (auto row : aggregated_calls) {
for (auto p : row) {
unique_headers.insert(p.first);
}
}

std::vector<std::string> headers = {"Name", "Duration (us)",
"Percent"}; // always include these headers
// always include these headers in this order
std::vector<std::string> headers = {"Name", "Duration (us)", "Percent",
"Device", "Count", "Argument Shapes"};
for (auto header : unique_headers) {
if (header != "Name" && header != "Duration (us)" && header != "Percent") {
if (std::find(headers.begin(), headers.end(), header) == headers.end()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we worried about this being quadratic in the number of unique headers, or will there always be a small number?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would assume the number of headers is going to be small.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, I just wasn't sure if there were other edge cases. In that case, looks good to me.

headers.push_back(header);
}
}
Expand Down