X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Fdebug%2Fprofiler.cpp;h=65cc71ced0876d6863f7613d6f99561e6a82244b;hp=38681ed9fd2d5103c685d567a88690600cda36a8;hb=HEAD;hpb=4798e6e5eac917b6225a1295fa5b118d88345237 diff --git a/source/debug/profiler.cpp b/source/debug/profiler.cpp index 38681ed..65cc71c 100644 --- a/source/debug/profiler.cpp +++ b/source/debug/profiler.cpp @@ -1,5 +1,4 @@ #include -#include #include "profiler.h" #include "profilingscope.h" @@ -8,20 +7,15 @@ using namespace std; namespace Msp { namespace Debug { -Profiler::Profiler(): - period(0), - inner(0) -{ } - void Profiler::set_period(unsigned p) { if(p==period) return; period = p; - for(map::iterator i=scopes.begin(); i!=scopes.end(); ++i) + for(auto &kvp: scopes) { - ScopeInfo &si = i->second; + ScopeInfo &si = kvp.second; if(p==0) si.history.clear(); else @@ -31,11 +25,11 @@ void Profiler::set_period(unsigned p) } } -void Profiler::add_scope(const std::string &name) +void Profiler::add_scope(const string &name) { if(!scopes.count(name)) { - map::iterator i = scopes.insert(map::value_type(name, ScopeInfo())).first; + auto i = scopes.insert(make_pair(name, ScopeInfo())).first; i->second.history.resize(period); } } @@ -49,10 +43,10 @@ ProfilingScope *Profiler::enter(ProfilingScope *ps) void Profiler::record(const ProfilingScope &scope) { - map::iterator i = scopes.find(scope.get_name()); + auto i = scopes.find(scope.get_name()); if(i==scopes.end()) { - i = scopes.insert(map::value_type(scope.get_name(), ScopeInfo())).first; + i = scopes.insert(make_pair(scope.get_name(), ScopeInfo())).first; i->second.first_call = scope.get_entry_time(); i->second.history.resize(period); } @@ -97,13 +91,5 @@ const Profiler::ScopeInfo &Profiler::get_scope(const string &sn) const return get_item(scopes, sn); } - -Profiler::ScopeInfo::ScopeInfo(): - calls(0), - calls_per_sec(0), - hist_pos(0), - hist_full(false) -{ } - } // namespace Debug } // namespace Msp