| 90 | } |
| 91 | |
| 92 | void StatsCalculator::OrderNodesByMetric( |
| 93 | SortingMetric metric, std::vector<const Detail*>* details) const { |
| 94 | std::priority_queue<std::pair<std::string, const Detail*>> sorted_list; |
| 95 | const int num_nodes = details_.size(); |
| 96 | |
| 97 | for (const auto& det : details_) { |
| 98 | const Detail* detail = &(det.second); |
| 99 | std::stringstream stream; |
| 100 | stream << std::setw(20) << std::right << std::setprecision(10) |
| 101 | << std::fixed; |
| 102 | |
| 103 | switch (metric) { |
| 104 | case BY_NAME: |
| 105 | stream << detail->name; |
| 106 | break; |
| 107 | case BY_RUN_ORDER: |
| 108 | stream << num_nodes - detail->run_order; |
| 109 | break; |
| 110 | case BY_TIME: |
| 111 | stream << detail->rel_end_us.avg(); |
| 112 | break; |
| 113 | case BY_MEMORY: |
| 114 | stream << detail->mem_used.avg(); |
| 115 | break; |
| 116 | case BY_TYPE: |
| 117 | stream << detail->type; |
| 118 | break; |
| 119 | default: |
| 120 | stream << ""; |
| 121 | break; |
| 122 | } |
| 123 | |
| 124 | sorted_list.emplace(stream.str(), detail); |
| 125 | } |
| 126 | |
| 127 | while (!sorted_list.empty()) { |
| 128 | auto entry = sorted_list.top(); |
| 129 | sorted_list.pop(); |
| 130 | details->push_back(entry.second); |
| 131 | } |
| 132 | } |
| 133 | |
| 134 | void StatsCalculator::ComputeStatsByType( |
| 135 | std::map<std::string, int64_t>* node_type_map_count, |