Support explicitly creating & destroying profiler frames
This commit is contained in:
parent
54fb90214f
commit
058505e9f0
2 changed files with 17 additions and 0 deletions
|
|
@ -16,7 +16,9 @@ namespace psemek::prof
|
|||
|
||||
~ profiler();
|
||||
|
||||
static void start_frame(std::string const & name);
|
||||
static void push(std::string const & name, std::chrono::duration<double> duration);
|
||||
static void end_frame(std::chrono::duration<double> duration);
|
||||
|
||||
template <typename Duration>
|
||||
static void push(std::string const & name, Duration duration)
|
||||
|
|
|
|||
|
|
@ -191,6 +191,14 @@ namespace psemek::prof
|
|||
current = current->parent;
|
||||
}
|
||||
|
||||
void profiler::start_frame(std::string const & name)
|
||||
{
|
||||
get_current();
|
||||
|
||||
std::lock_guard lock{*(current->mutex)};
|
||||
current = current->child(name);
|
||||
}
|
||||
|
||||
void profiler::push(std::string const & name, std::chrono::duration<double> duration)
|
||||
{
|
||||
get_current();
|
||||
|
|
@ -199,4 +207,11 @@ namespace psemek::prof
|
|||
current->child(name)->execution_time.push(duration.count());
|
||||
}
|
||||
|
||||
void profiler::end_frame(std::chrono::duration<double> duration)
|
||||
{
|
||||
std::lock_guard lock{*(current->mutex)};
|
||||
current->execution_time.push(duration.count());
|
||||
current = current->parent;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue