write profile, histroy count in print-out
parent
5d493a6493
commit
d895e6d033
|
@ -72,30 +72,36 @@ namespace blt::profiling {
|
||||||
|
|
||||||
total_difference /= (long) interval_vec.size();
|
total_difference /= (long) interval_vec.size();
|
||||||
|
|
||||||
// create a new name for the interval that includes the sample size
|
|
||||||
std::string new_name = "(";
|
|
||||||
new_name += std::to_string(interval_vec.size());
|
|
||||||
new_name += ") ";
|
|
||||||
new_name += name;
|
|
||||||
|
|
||||||
// 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({new_name, capture_interval{0, total_difference}});
|
averagedIntervals.insert({name, capture_interval{0, total_difference}});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void writeProfile(std::ofstream& out, const std::string& profileName, bool averageHistory) {
|
void writeProfile(std::ofstream& out, const std::string& profileName, bool averageHistory) {
|
||||||
auto& profile = profiles[profileName];
|
auto& profile = profiles[profileName];
|
||||||
const auto& intervals = profile.intervals;
|
const auto& intervals = profile.intervals;
|
||||||
|
const auto& intervals_hist = profile.historicalIntervals;
|
||||||
const auto& points = profile.points;
|
const auto& points = profile.points;
|
||||||
|
|
||||||
std::vector<IntervalComparable> ordered_vector;
|
std::vector<IntervalComparable> order_rows;
|
||||||
std::unordered_map<std::string, capture_interval> averaged_intervals;
|
std::unordered_map<std::string, capture_interval> averaged_intervals;
|
||||||
|
|
||||||
if (averageHistory)
|
if (averageHistory)
|
||||||
averageIntervals(profile.historicalIntervals, averaged_intervals);
|
averageIntervals(profile.historicalIntervals, averaged_intervals);
|
||||||
|
|
||||||
orderIntervals(averageHistory ? averaged_intervals : intervals, ordered_vector);
|
orderIntervals(averageHistory ? averaged_intervals : intervals, order_rows);
|
||||||
|
|
||||||
|
out << "Order,Count,Interval,Time (ms),Time (ns)\n";
|
||||||
|
int index = 1;
|
||||||
|
for (const auto& row : order_rows) {
|
||||||
|
out << std::to_string(index++) << ","
|
||||||
|
<< std::to_string(averageHistory ? intervals_hist.at(row.name).size() : 1) << ","
|
||||||
|
<< row.name << ","
|
||||||
|
<< std::to_string((double) row.difference / 1000000.0) << ","
|
||||||
|
<< std::to_string(row.difference) << "\n";
|
||||||
|
}
|
||||||
|
out.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
void printProfile(
|
void printProfile(
|
||||||
|
@ -103,27 +109,32 @@ namespace blt::profiling {
|
||||||
) {
|
) {
|
||||||
auto& profile = profiles[profileName];
|
auto& profile = profiles[profileName];
|
||||||
const auto& intervals = profile.intervals;
|
const auto& intervals = profile.intervals;
|
||||||
|
const auto& intervals_hist = profile.historicalIntervals;
|
||||||
const auto& points = profile.points;
|
const auto& points = profile.points;
|
||||||
|
|
||||||
std::vector<IntervalComparable> ordered_vector;
|
std::vector<IntervalComparable> ordered_rows;
|
||||||
std::unordered_map<std::string, capture_interval> averaged_intervals;
|
std::unordered_map<std::string, capture_interval> averaged_intervals;
|
||||||
|
|
||||||
if (averageHistory)
|
if (averageHistory)
|
||||||
averageIntervals(profile.historicalIntervals, averaged_intervals);
|
averageIntervals(profile.historicalIntervals, averaged_intervals);
|
||||||
|
|
||||||
orderIntervals(averageHistory ? averaged_intervals : intervals, ordered_vector);
|
orderIntervals(averageHistory ? averaged_intervals : intervals, ordered_rows);
|
||||||
|
|
||||||
string::TableFormatter formatter{profileName};
|
string::TableFormatter formatter{profileName};
|
||||||
formatter.addColumn({"Order"});
|
formatter.addColumn({"Order"});
|
||||||
|
formatter.addColumn({"Count"});
|
||||||
formatter.addColumn({"Interval"});
|
formatter.addColumn({"Interval"});
|
||||||
formatter.addColumn({"Time (ns)"});
|
|
||||||
formatter.addColumn({"Time (ms)"});
|
formatter.addColumn({"Time (ms)"});
|
||||||
|
formatter.addColumn({"Time (ns)"});
|
||||||
|
|
||||||
int index = 1;
|
int index = 1;
|
||||||
for (const auto& interval : ordered_vector) {
|
for (const auto& row : ordered_rows) {
|
||||||
formatter.addRow(
|
formatter.addRow(
|
||||||
{std::to_string(index++), interval.name, std::to_string(interval.difference),
|
{std::to_string(index++),
|
||||||
std::to_string((double)interval.difference / 1000000.0)}
|
std::to_string(averageHistory ? intervals_hist.at(row.name).size() : 1),
|
||||||
|
row.name,
|
||||||
|
std::to_string((double) row.difference / 1000000.0),
|
||||||
|
std::to_string(row.difference)}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue