| 80 | } |
| 81 | |
| 82 | void ProfTime::Dump(int method) |
| 83 | { |
| 84 | if(method == PROF_DUMP_DECREASE) |
| 85 | { |
| 86 | std::sort(record.begin(), record.end(), [](const TimeRecord& a, const TimeRecord& b) { |
| 87 | if(a.total_used_time > b.total_used_time) |
| 88 | return true; |
| 89 | else |
| 90 | return false; |
| 91 | }); |
| 92 | } |
| 93 | else if(method == PROF_DUMP_INCREASE) |
| 94 | { |
| 95 | std::sort(record.begin(), record.end(), [](const TimeRecord& a, const TimeRecord& b) { |
| 96 | if(a.total_used_time > b.total_used_time) |
| 97 | return false; |
| 98 | else |
| 99 | return true; |
| 100 | }); |
| 101 | } |
| 102 | |
| 103 | uint64_t accum_time = 0; |
| 104 | |
| 105 | for(unsigned int i = 0; i < record.size(); i++) |
| 106 | accum_time += record[i].total_used_time; |
| 107 | |
| 108 | int forward_count = 1; |
| 109 | int idx = 0; |
| 110 | for(unsigned int i = 0; i < record.size(); i++) |
| 111 | { |
| 112 | const TimeRecord& r = record[i]; |
| 113 | |
| 114 | if(r.count == 0) |
| 115 | continue; |
| 116 | |
| 117 | forward_count = r.count; |
| 118 | |
| 119 | std::printf("%3d [ %3.2f%% : %.3f ms ]", idx, 100.0 * r.total_used_time / accum_time, |
| 120 | ( float )(( unsigned long )r.total_used_time / 1000.f / r.count)); |
| 121 | |
| 122 | parser(r.ident, r.count, r.total_used_time); |
| 123 | idx += 1; |
| 124 | std::cout << "\n"; |
| 125 | } |
| 126 | |
| 127 | if(accum_time > 0) |
| 128 | { |
| 129 | std::printf("\ntotal accumulated time: %lu us. roughly [%lu] us per run\n", ( unsigned long )accum_time, |
| 130 | ( unsigned long )(accum_time / forward_count)); |
| 131 | } |
| 132 | } |
| 133 | |
| 134 | } // namespace TEngine |