8 Profiler IPDF::g_profiler;
10 void Profiler::BeginZone(std::string name)
12 if (!m_zones.count(name))
13 m_zones[name] = ProfileZone{0,0,0,0,0,0};
14 m_zones[name].tics_begin = SDL_GetPerformanceCounter();
15 m_zone_stack.push(name);
18 void Profiler::EndZone()
20 std::string name = m_zone_stack.top();
22 m_zones[name].tics_end = SDL_GetPerformanceCounter();
23 m_zones[name].tics_frame += m_zones[name].tics_end - m_zones[name].tics_begin;
24 m_zones[name].tics_total += m_zones[name].tics_end - m_zones[name].tics_begin;
25 m_zones[name].calls_frame++;
26 m_zones[name].calls_total++;
29 void Profiler::EndFrame()
31 // Zero all of the frame counts
32 for (auto& it : m_zones)
36 printf("perf_zone\t\"%s\"\t%lu %lu\t%lu %lu\n", it.first.c_str(), it.second.tics_frame * 1000 / SDL_GetPerformanceFrequency(), it.second.calls_frame, it.second.tics_total * 1000 / SDL_GetPerformanceFrequency(), it.second.calls_total);
38 it.second.tics_frame = 0;
39 it.second.calls_frame = 0;