cleanup printing

remove the needless addition of \n to the end of lines
v1
Brett 2023-03-04 11:52:54 -05:00
parent 643053c409
commit 5d493a6493
2 changed files with 16 additions and 11 deletions

View File

@ -54,7 +54,7 @@ namespace blt::profiling {
bool averageHistory = false
);
void writeProfile(std::ofstream& out, const std::string& profileName);
void writeProfile(std::ofstream& out, const std::string& profileName, bool averageHistory = false);
void discardProfiles();

View File

@ -26,10 +26,10 @@ namespace blt::profiling {
difference(difference), name(std::move(name)) {}
};
inline void print(const std::vector<std::string>& lines, logging::LOG_LEVEL level) {
inline void println(const std::vector<std::string>&& lines, logging::LOG_LEVEL level) {
auto& logger = logging::getLoggerFromLevel(level);
for (const auto& line : lines)
logger << line;
logger << line << "\n";
}
/**
@ -84,8 +84,18 @@ namespace blt::profiling {
}
}
void writeProfile(std::ofstream& out, const std::string& profileName, bool ordered) {
void writeProfile(std::ofstream& out, const std::string& profileName, bool averageHistory) {
auto& profile = profiles[profileName];
const auto& intervals = profile.intervals;
const auto& points = profile.points;
std::vector<IntervalComparable> ordered_vector;
std::unordered_map<std::string, capture_interval> averaged_intervals;
if (averageHistory)
averageIntervals(profile.historicalIntervals, averaged_intervals);
orderIntervals(averageHistory ? averaged_intervals : intervals, ordered_vector);
}
void printProfile(
@ -116,13 +126,8 @@ namespace blt::profiling {
std::to_string((double)interval.difference / 1000000.0)}
);
}
std::vector<std::string> updatedLines;
const auto& lines = formatter.createTable(true, true);
for (const auto& line : lines)
updatedLines.emplace_back(line + "\n");
print(updatedLines, loggingLevel);
println(formatter.createTable(true, true), loggingLevel);
}
// --- small helper functions below ---