X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;ds=sidebyside;f=source%2Fdebug%2Fprofiler.cpp;h=6cce271983022302a6a3820acf20e049d02d7143;hb=27efc167cb10ee03c1d2a6711dd149d1093179c8;hp=e3d98408d6d2244c47da824c8cf0fde3c0998c89;hpb=f4cf84ddec17f4fec0d9ba7e6814a8af8ff50395;p=libs%2Fcore.git diff --git a/source/debug/profiler.cpp b/source/debug/profiler.cpp index e3d9840..6cce271 100644 --- a/source/debug/profiler.cpp +++ b/source/debug/profiler.cpp @@ -1,6 +1,7 @@ #include #include #include "profiler.h" +#include "profilingscope.h" using namespace std; @@ -45,24 +46,25 @@ ProfilingScope *Profiler::enter(ProfilingScope *ps) return old; } -void Profiler::record(const string &scope_name, const string &parent, const Time::TimeDelta &time, const Time::TimeDelta &child_t) +void Profiler::record(const ProfilingScope &scope) { - map::iterator i = scopes.find(scope_name); + map::iterator i = scopes.find(scope.get_name()); if(i==scopes.end()) { - i = scopes.insert(map::value_type(scope_name, ScopeInfo())).first; + i = scopes.insert(map::value_type(scope.get_name(), ScopeInfo())).first; i->second.history.resize(period); } ScopeInfo &si = i->second; ++si.calls; - ++si.called_from[parent]; - si.total_time += time; - si.self_time += time-child_t; + if(scope.get_parent()) + ++si.called_from[scope.get_parent()->get_name()]; + si.total_time += scope.get_time_spent(); + si.self_time += scope.get_time_spent()-scope.get_child_time(); if(period) { - si.avg_time += time/period-si.history[si.hist_pos]/period; - si.history[si.hist_pos++] = time; + si.avg_time += scope.get_time_spent()/period-si.history[si.hist_pos]/period; + si.history[si.hist_pos++] = scope.get_time_spent(); if(si.hist_pos>=period) si.hist_pos -= period; } @@ -70,7 +72,7 @@ void Profiler::record(const string &scope_name, const string &parent, const Time si.avg_time = si.total_time/si.calls; } -const Profiler::ScopeInfo &Profiler::scope(const string &sn) const +const Profiler::ScopeInfo &Profiler::get_scope(const string &sn) const { return get_item(scopes, sn); }