make write profile work
parent
9860845831
commit
8133553ed8
|
@ -74,7 +74,8 @@ namespace blt
|
|||
std::string name;
|
||||
|
||||
explicit profile_t(std::string name): name(std::move(name))
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
profile_t(const profile_t& p) = delete;
|
||||
|
||||
|
@ -99,7 +100,9 @@ namespace blt
|
|||
void printProfile(profile_t& profiler, std::uint32_t flags = AVERAGE_HISTORY | PRINT_CYCLES | PRINT_THREAD | PRINT_WALL,
|
||||
sort_by sort = sort_by::CYCLES, blt::logging::log_level log_level = blt::logging::log_level::NONE);
|
||||
|
||||
void writeProfile(std::ifstream& stream, const profile_t& profiler);
|
||||
void writeProfile(std::ostream& stream, profile_t& profiler,
|
||||
std::uint32_t flags = AVERAGE_HISTORY | PRINT_CYCLES | PRINT_THREAD | PRINT_WALL,
|
||||
sort_by sort = sort_by::CYCLES);
|
||||
|
||||
void clearProfile(profile_t& profiler);
|
||||
|
||||
|
@ -112,13 +115,16 @@ namespace blt
|
|||
void printProfile(const std::string& profile_name, std::uint32_t flags = AVERAGE_HISTORY | PRINT_CYCLES | PRINT_THREAD | PRINT_WALL,
|
||||
sort_by sort = sort_by::CYCLES, blt::logging::log_level log_level = blt::logging::log_level::NONE);
|
||||
|
||||
void writeProfile(std::ifstream& stream, const std::string& profile_name);
|
||||
void writeProfile(std::ostream& stream, const std::string& profile_name,
|
||||
std::uint32_t flags = AVERAGE_HISTORY | PRINT_CYCLES | PRINT_THREAD | PRINT_WALL,
|
||||
sort_by sort = sort_by::CYCLES);
|
||||
}
|
||||
|
||||
class auto_interval
|
||||
{
|
||||
private:
|
||||
interval_t* iv;
|
||||
|
||||
public:
|
||||
auto_interval(std::string interval_name, profile_t& profiler)
|
||||
{
|
||||
|
@ -140,7 +146,6 @@ namespace blt
|
|||
blt::endInterval(iv);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#ifdef BLT_DISABLE_PROFILING
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 0bad0987f1989294e73cdb1ebf41c75f49cdb0c1
|
||||
Subproject commit d88c5e15079047777b418132ece5879e7c9aaa2b
|
|
@ -89,11 +89,6 @@ namespace blt
|
|||
profiler.cycle_intervals.clear();
|
||||
}
|
||||
|
||||
void writeProfile(std::ifstream&, const profile_t&)
|
||||
{
|
||||
BLT_WARN("Write profile for V2 is currently a TODO");
|
||||
}
|
||||
|
||||
void sort_intervals(std::vector<interval_t*>& intervals, sort_by sort, bool)
|
||||
{
|
||||
std::function<bool(const interval_t* a, const interval_t* b)> sort_func;
|
||||
|
@ -137,12 +132,7 @@ namespace blt
|
|||
return container;
|
||||
}
|
||||
|
||||
inline void println(const std::vector<std::string>&& lines, logging::log_level level) {
|
||||
for (const auto& line : lines)
|
||||
BLT_LOG_STREAM(level) << line << "\n";
|
||||
}
|
||||
|
||||
void printProfile(profile_t& profiler, std::uint32_t flags, sort_by sort, blt::logging::log_level log_level)
|
||||
void writeProfile(std::ostream& stream, profile_t& profiler, std::uint32_t flags, sort_by sort)
|
||||
{
|
||||
bool printHistory = flags & AVERAGE_HISTORY;
|
||||
bool printCycles = flags & PRINT_CYCLES;
|
||||
|
@ -192,7 +182,16 @@ namespace blt
|
|||
formatter.addRow(row);
|
||||
}
|
||||
|
||||
println(formatter.createTable(true, true), log_level);
|
||||
auto lines = formatter.createTable(true, true);
|
||||
for (const auto& line : lines)
|
||||
stream << line << "\n";
|
||||
}
|
||||
|
||||
void printProfile(profile_t& profiler, const std::uint32_t flags, sort_by sort, blt::logging::log_level log_level)
|
||||
{
|
||||
std::stringstream stream;
|
||||
writeProfile(stream, profiler, flags, sort);
|
||||
BLT_LOG_STREAM(log_level) << stream.str();
|
||||
}
|
||||
|
||||
profile_t::~profile_t()
|
||||
|
@ -226,7 +225,7 @@ namespace blt
|
|||
blt::endInterval(profiles[profile_name].at(interval_name));
|
||||
}
|
||||
|
||||
void _internal::writeProfile(std::ifstream& stream, const std::string& profile_name)
|
||||
void _internal::writeProfile(std::ostream& stream, const std::string& profile_name, std::uint32_t flags, sort_by sort)
|
||||
{
|
||||
if (profiles.find(profile_name) == profiles.end())
|
||||
return;
|
||||
|
@ -234,7 +233,7 @@ namespace blt
|
|||
profile_t profile{profile_name};
|
||||
for (const auto& i : pref)
|
||||
profile.intervals.push_back(i.second);
|
||||
blt::writeProfile(stream, profile);
|
||||
blt::writeProfile(stream, profile, flags, sort);
|
||||
profiles.erase(profile_name);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue