ManaPlus
Functions
Perf Namespace Reference

Functions

void init ()
 
void nextFrame ()
 
void selectWorstFrame ()
 
int getTime (const size_t frameId, const size_t counterId)
 
int getWorstTime (const size_t counterId)
 

Function Documentation

◆ getTime()

int Perf::getTime ( const size_t  frameId,
const size_t  counterId 
)

Definition at line 111 of file perfstat.cpp.

113  {
114  const PerfStats &perf = perfStats[frameId];
115  const int val1 = perf.ticks[0];
116  const int val2 = perf.ticks[counterId];
117  if (val2 >= val1)
118  return val2 - val1;
119  return val1 - val2;
120  }
PerfStats perfStats[PERFSTAT_MAX]
Definition: perfstat.cpp:30
int ticks[16]
Definition: perfstat.h:39

References perfStats, and PerfStats::ticks.

Referenced by StatDebugTab::action(), StatDebugTab::logic(), and selectWorstFrame().

◆ getWorstTime()

int Perf::getWorstTime ( const size_t  counterId)

Definition at line 122 of file perfstat.cpp.

123  {
124  const int val1 = worstFrameStats.ticks[0];
125  const int val2 = worstFrameStats.ticks[counterId];
126  if (val2 >= val1)
127  return val2 - val1;
128  return val1 - val2;
129  }
PerfStats worstFrameStats
Definition: perfstat.cpp:35

References PerfStats::ticks, and worstFrameStats.

Referenced by StatDebugTab::action(), and StatDebugTab::logic().

◆ init()

void Perf::init ( )

Definition at line 41 of file perfstat.cpp.

42  {
43  logger->log("perf stats init");
44  worstTime = -1;
45  perfFrameId = 0;
46  prevPerfFrameId = 0;
47  for (size_t f = 0; f < PERFSTAT_LAST_STAT; f ++)
48  {
49  worstFrameStats.ticks[f] = 0;
50  }
51  for (size_t f = 0; f < PERFSTAT_MAX; f ++)
52  {
53  PerfStats &perf = perfStats[f];
54  for (size_t d = 0; d < PERFSTAT_LAST_STAT; d ++)
55  {
56  perf.ticks[d] = 0;
57  }
58  }
59  skipPerfFrames = 0;
60  }
void log(const char *const log_text,...)
Definition: logger.cpp:269
static const size_t PERFSTAT_MAX
Definition: perfstat.h:27
static const size_t PERFSTAT_LAST_STAT
Definition: perfstat.h:28
Logger * logger
Definition: logger.cpp:89
int worstTime
Definition: perfstat.cpp:36
size_t prevPerfFrameId
Definition: perfstat.cpp:33
int skipPerfFrames
Definition: perfstat.cpp:37
size_t perfFrameId
Definition: perfstat.cpp:32

References Logger::log(), logger, perfFrameId, PERFSTAT_LAST_STAT, PERFSTAT_MAX, perfStats, prevPerfFrameId, skipPerfFrames, PerfStats::ticks, worstFrameStats, and worstTime.

Referenced by StatDebugTab::action(), and Game::changeMap().

◆ nextFrame()

void Perf::nextFrame ( )

Definition at line 62 of file perfstat.cpp.

63  {
64  if (skipPerfFrames > 0)
65  {
66  skipPerfFrames --;
67 // logger->log("skip frames: %d", skipPerfFrames);
68  return;
69  }
70  else if (skipPerfFrames < 0)
71  {
72  return;
73  }
75  perfFrameId ++;
77  {
78  perfFrameId = 0;
80  }
82  }
void selectWorstFrame()
Definition: perfstat.cpp:84
int * perfFrame
Definition: perfstat.cpp:34

References perfFrame, perfFrameId, PERFSTAT_MAX, perfStats, prevPerfFrameId, selectWorstFrame(), skipPerfFrames, and PerfStats::ticks.

◆ selectWorstFrame()

void Perf::selectWorstFrame ( )

Definition at line 84 of file perfstat.cpp.

85  {
86  int time = worstTime;
87  int index = -1;
88  for (size_t f = 0; f < PERFSTAT_MAX; f ++)
89  {
90  if (f == perfFrameId)
91  continue;
92  const int time1 = Perf::getTime(f, PERFSTAT_FPS_STAT - 1);
93  if (time1 > time)
94  {
95  time = time1;
96  index = CAST_S32(f);
97  }
98  }
99  if (index >= 0)
100  {
101  worstFrameStats = perfStats[index];
102  logger->log("worst frame: %d, %d",
103  perfStats[index].ticks[PERFSTAT_FPS_STAT - 1] -
104  perfStats[index].ticks[0],
107  worstTime = time;
108  }
109  }
#define CAST_S32
Definition: cast.h:30
static const size_t PERFSTAT_FPS_STAT
Definition: perfstat.h:29
int getTime(const size_t frameId, const size_t counterId)
Definition: perfstat.cpp:111

References CAST_S32, getTime(), Logger::log(), logger, perfFrameId, PERFSTAT_FPS_STAT, PERFSTAT_MAX, perfStats, PerfStats::ticks, worstFrameStats, and worstTime.

Referenced by nextFrame().