diff --git a/libs/prof/include/psemek/prof/profiler.hpp b/libs/prof/include/psemek/prof/profiler.hpp index bd1796c8..daa9d935 100644 --- a/libs/prof/include/psemek/prof/profiler.hpp +++ b/libs/prof/include/psemek/prof/profiler.hpp @@ -3,7 +3,7 @@ #include #include -#include +#include namespace psemek::prof { @@ -12,7 +12,7 @@ namespace psemek::prof struct profiler { - profiler(std::string const & name); + profiler(std::string_view name); profiler(profiler && other); profiler(profiler const & other) = delete; @@ -21,12 +21,12 @@ namespace psemek::prof ~profiler(); - static void start_frame(std::string const & name); - static void push(std::string const & name, std::chrono::duration duration, std::size_t count = 1); + static void start_frame(std::string_view name); + static void push(std::string_view name, std::chrono::duration duration, std::size_t count = 1); static void end_frame(std::chrono::duration duration); template - static void push(std::string const & name, Duration duration, std::size_t count = 1) + static void push(std::string_view name, Duration duration, std::size_t count = 1) { push(name, std::chrono::duration_cast>(duration), count); } diff --git a/libs/prof/source/profiler.cpp b/libs/prof/source/profiler.cpp index a7f03b03..6d1785a3 100644 --- a/libs/prof/source/profiler.cpp +++ b/libs/prof/source/profiler.cpp @@ -23,15 +23,15 @@ namespace psemek::prof util::statistics_log_bucket execution_time{0.05}; - std::map children; + std::map> children; std::vector::iterator> children_list; - profiler_tree * child(std::string const & name) + profiler_tree * child(std::string_view const & name) { auto it = children.find(name); if (it == children.end()) { - it = children.insert({name, profiler_tree{}}).first; + it = children.insert({std::string(name), profiler_tree{}}).first; it->second.parent = this; it->second.mutex = mutex; children_list.push_back(it); @@ -174,7 +174,7 @@ namespace psemek::prof dump_impl(merged_tree(), 0, level); } - profiler::profiler(std::string const & name) + profiler::profiler(std::string_view name) { get_current(); @@ -204,7 +204,7 @@ namespace psemek::prof report(); } - void profiler::start_frame(std::string const & name) + void profiler::start_frame(std::string_view name) { get_current(); @@ -212,7 +212,7 @@ namespace psemek::prof current = current->child(name); } - void profiler::push(std::string const & name, std::chrono::duration duration, std::size_t count) + void profiler::push(std::string_view name, std::chrono::duration duration, std::size_t count) { get_current();