#include <msp/core/maputils.h>
-#include <msp/time/units.h>
#include "profiler.h"
#include "profilingscope.h"
namespace Msp {
namespace Debug {
-Profiler::Profiler():
- period(0),
- inner(0)
-{ }
-
void Profiler::set_period(unsigned p)
{
if(p==period)
return;
period = p;
- for(map<string, ScopeInfo>::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
}
}
-void Profiler::add_scope(const std::string &name)
+void Profiler::add_scope(const string &name)
{
if(!scopes.count(name))
{
- map<string, ScopeInfo>::iterator i = scopes.insert(map<string, ScopeInfo>::value_type(name, ScopeInfo())).first;
+ auto i = scopes.insert(make_pair(name, ScopeInfo())).first;
i->second.history.resize(period);
}
}
void Profiler::record(const ProfilingScope &scope)
{
- map<string, ScopeInfo>::iterator i = scopes.find(scope.get_name());
+ auto i = scopes.find(scope.get_name());
if(i==scopes.end())
{
- i = scopes.insert(map<string, ScopeInfo>::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);
}
return get_item(scopes, sn);
}
-
-Profiler::ScopeInfo::ScopeInfo():
- calls(0),
- calls_per_sec(0),
- hist_pos(0),
- hist_full(false)
-{ }
-
} // namespace Debug
} // namespace Msp