Ordered table pretty print

v1
Brett 2023-01-27 09:58:51 -05:00
parent f68f23ae30
commit 42b912604d
4 changed files with 42 additions and 7 deletions

View File

@ -1,7 +1,6 @@
cmake_minimum_required(VERSION 3.24)
project(BLT)
project(BLT VERSION 0.3.1)
set(CMAKE_PROJECT_VERSION 0.3a)
set(CMAKE_CXX_STANDARD 17)
option(BUILD_STD "Build the BLT standard utilities." ON)

View File

@ -181,13 +181,16 @@ CMAKE_PROJECT_HOMEPAGE_URL:STATIC=
CMAKE_PROJECT_NAME:STATIC=BLT_TESTS
//Value Computed by CMake
CMAKE_PROJECT_VERSION_MAJOR:STATIC=1
CMAKE_PROJECT_VERSION:STATIC=0.3.1
//Value Computed by CMake
CMAKE_PROJECT_VERSION_MAJOR:STATIC=0
//Value Computed by CMake
CMAKE_PROJECT_VERSION_MINOR:STATIC=3
//Value Computed by CMake
CMAKE_PROJECT_VERSION_PATCH:STATIC=8
CMAKE_PROJECT_VERSION_PATCH:STATIC=1
//Value Computed by CMake
CMAKE_PROJECT_VERSION_TWEAK:STATIC=

View File

@ -4,7 +4,7 @@ Standard Files /home/brett/Documents/code/c++/BLT/src/blt/std/format.cpp;/home/b
Profiler Files /home/brett/Documents/code/c++/BLT/src/blt/profiling/profiler.cpp
Source: /home/brett/Documents/code/c++/BLT
Current Source: /home/brett/Documents/code/c++/BLT
BLT 0.3a Successfully included!
BLT 0.3.1 Successfully included!
BLT tests included!
-- Configuring done
-- Generating done

View File

@ -95,7 +95,7 @@ namespace blt::profiling {
for (const auto& interval : intervals) {
const auto difference = interval.second.end - interval.second.start;
formatter.addRow({interval.first, std::to_string(difference), std::to_string(difference/1000000)});
formatter.addRow({interval.first, std::to_string(difference), std::to_string(difference/1000000.0)});
}
std::vector<std::string> updatedLines;
@ -127,7 +127,7 @@ namespace blt::profiling {
return {longestName, longestIntervalTime};
}
void printOrderedProfile(const std::string& profileName, int loggingLevel) {
void printOrderedProfileOld(const std::string& profileName, int loggingLevel) {
std::vector<std::string> lines;
const auto& profile = profiles[profileName];
const auto& intervals = profile.intervals;
@ -174,6 +174,39 @@ namespace blt::profiling {
print(lines, loggingLevel);
}
void printOrderedProfile(const std::string& profileName, int loggingLevel) {
const auto& profile = profiles[profileName];
const auto& intervals = profile.intervals;
const auto& points = profile.points;
std::vector<timeOrderContainer> unorderedIntervalVector;
for (const auto& interval : intervals) {
const auto difference = interval.second.end - interval.second.start;
unorderedIntervalVector.emplace_back(difference, interval.first);
}
std::sort(unorderedIntervalVector.begin(), unorderedIntervalVector.end(), timeCompare);
string::TableFormatter formatter;
formatter.addColumn({"Order"});
formatter.addColumn({"Interval"});
formatter.addColumn({"Time (ns)"});
formatter.addColumn({"Time (ms)"});
int index = 1;
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)});
}
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);
}
void discardProfiles() {
profiles = {};
}