X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=src%2Fprofiler.cpp;h=13595af5c2f97c8a4b1166b8707312c57ccb9079;hb=refs%2Fheads%2Fmaster;hp=f718637d72e6057e1f95a594bb6a9ea4115786fb;hpb=f0b6c9b6b95fde134927c395afbfbbbc057868e6;p=ipdf%2Fcode.git diff --git a/src/profiler.cpp b/src/profiler.cpp index f718637..13595af 100644 --- a/src/profiler.cpp +++ b/src/profiler.cpp @@ -15,6 +15,14 @@ void Profiler::BeginZone(std::string name) m_zone_stack.push(name); } +void Profiler::AddCounter(std::string name, uint64_t amt) +{ + if (!m_counters.count(name)) + m_counters[name] = amt; + else + m_counters[name] += amt; +} + void Profiler::EndZone() { std::string name = m_zone_stack.top(); @@ -38,4 +46,13 @@ void Profiler::EndFrame() it.second.tics_frame = 0; it.second.calls_frame = 0; } + + for (auto& it : m_counters) + { + if (m_enabled) + { + printf("perf_counter\t\"%s\"\t%lu\n", it.first.c_str(), it.second); + } + it.second = 0; + } }