Non puoi selezionare più di 25 argomenti
Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
|
- //
- // Deus Hax (working title)
- // Copyright (c) 2010 Sam Hocevar <sam@hocevar.net>
- //
-
- #if defined HAVE_CONFIG_H
- # include "config.h"
- #endif
-
- #include <cstdlib>
- #include <cstdio>
- #include <stdint.h>
-
- #include "core.h"
-
- /*
- * Profiler implementation class
- */
-
- static class ProfilerData
- {
- friend class Profiler;
-
- static int const HISTORY = 32;
-
- public:
- ProfilerData()
- {
- for (int i = 0; i < HISTORY; i++)
- history[i] = 0.0f;
- avg = max = 0.0f;
- }
-
- private:
- float history[HISTORY];
- Timer timer;
- float avg, max;
- }
- data[Profiler::STAT_COUNT];
-
- /*
- * Profiler public class
- */
-
- void Profiler::Start(int id)
- {
- data[id].timer.GetMs();
- }
-
- void Profiler::Stop(int id)
- {
- float deltams = data[id].timer.GetMs();
-
- data[id].history[Ticker::GetFrameNum() % ProfilerData::HISTORY] = deltams;
- data[id].avg = 0.0f;
- data[id].max = 0.0f;
-
- for (int i = 0; i < ProfilerData::HISTORY; i++)
- {
- data[id].avg += data[id].history[i];
- if (data[id].history[i] > data[id].max)
- data[id].max = data[id].history[i];
- }
- data[id].avg /= ProfilerData::HISTORY;
- }
-
- float Profiler::GetAvg(int id)
- {
- return data[id].avg;
- }
-
- float Profiler::GetMax(int id)
- {
- return data[id].max;
- }
|