Add history vector size to readout

v1
Brett 2023-02-15 09:50:20 -05:00
parent 596c75dc6f
commit 7a181e0c71
1 changed files with 23 additions and 13 deletions

View File

@ -54,7 +54,7 @@ namespace blt::profiling {
} }
void printProfile(const std::string& profileName, blt::logging::LOG_LEVEL loggingLevel, bool averageHistory, bool ignoreNegatives) { void printProfile(const std::string& profileName, blt::logging::LOG_LEVEL loggingLevel, bool averageHistory, bool ignoreNegatives) {
string::TableFormatter formatter {profileName}; string::TableFormatter formatter{profileName};
formatter.addColumn({"Interval"}); formatter.addColumn({"Interval"});
formatter.addColumn({"Time (ns)"}); formatter.addColumn({"Time (ns)"});
formatter.addColumn({"Time (ms)"}); formatter.addColumn({"Time (ms)"});
@ -74,7 +74,11 @@ namespace blt::profiling {
total_difference += difference; total_difference += difference;
} }
total_difference /= (long) history.size(); total_difference /= (long) history.size();
formatter.addRow({interval.first, std::to_string(total_difference), std::to_string((double) total_difference / 1000000.0)}); std::string name = "(";
name += std::to_string(history.size());
name += ") ";
name += interval.first;
formatter.addRow({name, std::to_string(total_difference), std::to_string((double) total_difference / 1000000.0)});
} else { } else {
const auto difference = interval.second.end - interval.second.start; const auto difference = interval.second.end - interval.second.start;
if (ignoreNegatives && difference < 0) if (ignoreNegatives && difference < 0)
@ -122,7 +126,11 @@ namespace blt::profiling {
total_difference += difference; total_difference += difference;
} }
total_difference /= (long) history.size(); total_difference /= (long) history.size();
unorderedIntervalVector.emplace_back(total_difference, std::string("(H) ") += interval.first); std::string name = "(";
name += std::to_string(history.size());
name += ") ";
name += interval.first;
unorderedIntervalVector.emplace_back(total_difference, name);
} else { } else {
const auto difference = interval.second.end - interval.second.start; const auto difference = interval.second.end - interval.second.start;
if (ignoreNegatives && difference < 0) if (ignoreNegatives && difference < 0)
@ -133,7 +141,7 @@ namespace blt::profiling {
std::sort(unorderedIntervalVector.begin(), unorderedIntervalVector.end(), timeCompare); std::sort(unorderedIntervalVector.begin(), unorderedIntervalVector.end(), timeCompare);
string::TableFormatter formatter {profileName}; string::TableFormatter formatter{profileName};
formatter.addColumn({"Order"}); formatter.addColumn({"Order"});
formatter.addColumn({"Interval"}); formatter.addColumn({"Interval"});
formatter.addColumn({"Time (ns)"}); formatter.addColumn({"Time (ns)"});
@ -141,7 +149,9 @@ namespace blt::profiling {
int index = 1; int index = 1;
for (const auto& interval : unorderedIntervalVector) { for (const auto& interval : unorderedIntervalVector) {
formatter.addRow({std::to_string(index++), interval.name, std::to_string(interval.difference), std::to_string(interval.difference / 1000000.0)}); formatter.addRow(
{std::to_string(index++), interval.name, std::to_string(interval.difference), std::to_string(interval.difference / 1000000.0)}
);
} }
std::vector<std::string> updatedLines; std::vector<std::string> updatedLines;