Add total to profiler
parent
b62d4bfe78
commit
13b7c3905b
|
@ -21,9 +21,13 @@ namespace blt::profiling {
|
||||||
struct IntervalComparable {
|
struct IntervalComparable {
|
||||||
long difference;
|
long difference;
|
||||||
std::string name;
|
std::string name;
|
||||||
|
std::uint64_t total;
|
||||||
|
|
||||||
IntervalComparable(long difference, std::string name):
|
IntervalComparable(long difference, std::string name):
|
||||||
difference(difference), name(std::move(name)) {}
|
difference(difference), name(std::move(name)), total(difference) {}
|
||||||
|
|
||||||
|
IntervalComparable(long difference, std::string name, std::uint64_t total):
|
||||||
|
difference(difference), name(std::move(name)), total(total) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
inline void println(const std::vector<std::string>&& lines, logging::LOG_LEVEL level) {
|
inline void println(const std::vector<std::string>&& lines, logging::LOG_LEVEL level) {
|
||||||
|
@ -37,11 +41,15 @@ namespace blt::profiling {
|
||||||
*/
|
*/
|
||||||
inline void orderIntervals(
|
inline void orderIntervals(
|
||||||
const std::unordered_map<std::string, capture_interval>& unordered,
|
const std::unordered_map<std::string, capture_interval>& unordered,
|
||||||
std::vector<IntervalComparable>& ordered
|
std::vector<IntervalComparable>& ordered, bool history
|
||||||
) {
|
) {
|
||||||
// copy
|
// copy
|
||||||
for (const auto& i : unordered)
|
for (const auto& i : unordered) {
|
||||||
|
if (history)
|
||||||
|
ordered.emplace_back(i.second.end, i.first, i.second.start);
|
||||||
|
else
|
||||||
ordered.emplace_back(i.second.end - i.second.start, i.first);
|
ordered.emplace_back(i.second.end - i.second.start, i.first);
|
||||||
|
}
|
||||||
|
|
||||||
// sort
|
// sort
|
||||||
std::sort(
|
std::sort(
|
||||||
|
@ -63,7 +71,9 @@ namespace blt::profiling {
|
||||||
|
|
||||||
// we can exploit how the order func works by supplying the difference into end,
|
// we can exploit how the order func works by supplying the difference into end,
|
||||||
// which sorts correctly despite not being a true interval.
|
// which sorts correctly despite not being a true interval.
|
||||||
averagedIntervals.insert({name, capture_interval{0, (long)(interval_vec.total / interval_vec.count)}});
|
averagedIntervals.insert(
|
||||||
|
{name, capture_interval{(long)interval_vec.total, (long) (interval_vec.total / interval_vec.count)}}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,16 +89,17 @@ namespace blt::profiling {
|
||||||
if (averageHistory)
|
if (averageHistory)
|
||||||
averageIntervals(intervals_total, averaged_intervals);
|
averageIntervals(intervals_total, averaged_intervals);
|
||||||
|
|
||||||
orderIntervals(averageHistory ? averaged_intervals : intervals, order_rows);
|
orderIntervals(averageHistory ? averaged_intervals : intervals, order_rows, averageHistory);
|
||||||
|
|
||||||
out << "Order,Count,Interval,Time (ms),Time (ns)\n";
|
out << "Order,Count,Interval,Time (ms),Time (ns),Total (ms)\n";
|
||||||
int index = 1;
|
int index = 1;
|
||||||
for (const auto& row : order_rows) {
|
for (const auto& row : order_rows) {
|
||||||
out << std::to_string(index++) << ","
|
out << std::to_string(index++) << ","
|
||||||
<< std::to_string(averageHistory ? intervals_total.at(row.name).count : 1) << ","
|
<< std::to_string(averageHistory ? intervals_total.at(row.name).count : 1) << ","
|
||||||
<< row.name << ","
|
<< row.name << ","
|
||||||
<< std::to_string((double) row.difference / 1000000.0) << ","
|
<< std::to_string((double) row.difference / 1000000.0) << ","
|
||||||
<< std::to_string(row.difference) << "\n";
|
<< std::to_string(row.difference) << ","
|
||||||
|
<< std::to_string(row.total) << "\n";
|
||||||
}
|
}
|
||||||
out.flush();
|
out.flush();
|
||||||
}
|
}
|
||||||
|
@ -107,7 +118,7 @@ namespace blt::profiling {
|
||||||
if (averageHistory)
|
if (averageHistory)
|
||||||
averageIntervals(intervals_total, averaged_intervals);
|
averageIntervals(intervals_total, averaged_intervals);
|
||||||
|
|
||||||
orderIntervals(averageHistory ? averaged_intervals : intervals, ordered_rows);
|
orderIntervals(averageHistory ? averaged_intervals : intervals, ordered_rows, averageHistory);
|
||||||
|
|
||||||
string::TableFormatter formatter{profileName};
|
string::TableFormatter formatter{profileName};
|
||||||
formatter.addColumn({"Order"});
|
formatter.addColumn({"Order"});
|
||||||
|
@ -115,6 +126,7 @@ namespace blt::profiling {
|
||||||
formatter.addColumn({"Interval"});
|
formatter.addColumn({"Interval"});
|
||||||
formatter.addColumn({"Time (ms)"});
|
formatter.addColumn({"Time (ms)"});
|
||||||
formatter.addColumn({"Time (ns)"});
|
formatter.addColumn({"Time (ns)"});
|
||||||
|
formatter.addColumn({"Total (ms)"});
|
||||||
|
|
||||||
int index = 1;
|
int index = 1;
|
||||||
for (const auto& row : ordered_rows) {
|
for (const auto& row : ordered_rows) {
|
||||||
|
@ -123,7 +135,8 @@ namespace blt::profiling {
|
||||||
std::to_string(averageHistory ? intervals_total.at(row.name).count : 1),
|
std::to_string(averageHistory ? intervals_total.at(row.name).count : 1),
|
||||||
row.name,
|
row.name,
|
||||||
std::to_string((double) row.difference / 1000000.0),
|
std::to_string((double) row.difference / 1000000.0),
|
||||||
std::to_string(row.difference)}
|
std::to_string(row.difference),
|
||||||
|
std::to_string(row.total)}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue