diff --git a/libs/prof/include/psemek/prof/profiler.hpp b/libs/prof/include/psemek/prof/profiler.hpp index 0c569b08..25f61f05 100644 --- a/libs/prof/include/psemek/prof/profiler.hpp +++ b/libs/prof/include/psemek/prof/profiler.hpp @@ -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 duration); + static void end_frame(std::chrono::duration duration); template static void push(std::string const & name, Duration duration) diff --git a/libs/prof/source/profiler.cpp b/libs/prof/source/profiler.cpp index b2bf2086..b48d58c8 100644 --- a/libs/prof/source/profiler.cpp +++ b/libs/prof/source/profiler.cpp @@ -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 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 duration) + { + std::lock_guard lock{*(current->mutex)}; + current->execution_time.push(duration.count()); + current = current->parent; + } + }