Rise
The Vieneo Province
performance.cpp
Go to the documentation of this file.
1 #include "performance.h"
2 #include "GameClass.h"
3 
5 {
6  logger = prmLogger;
7 
8  fm_min = 9999.0;
9  fm_max = fm_avg = 0.0;
10  fm_count = 0;
11 
12  start.QuadPart = 0;
13  stop.QuadPart = 0;
14  QueryPerformanceFrequency(&frequency);
15 }
16 
17 double CStopWatch::LIToSecs(LARGE_INTEGER & L)
18 {
19  return ((double)L.QuadPart / (double)frequency.QuadPart);
20 }
21 
23 {
24  QueryPerformanceCounter(&start);
25 }
26 
28 {
29  QueryPerformanceCounter(&stop);
31 }
32 
34 {
35  LARGE_INTEGER time;
36  time.QuadPart = stop.QuadPart - start.QuadPart;
37  double elapsed = LIToSecs(time);
38  if (elapsed < fm_min)
39  fm_min = elapsed;
40  if (elapsed > fm_max)
41  fm_max = elapsed;
42  fm_avg += elapsed;
43  fm_count++;
44 }
45 
46 void CStopWatch::Report(const char* caption) const
47 {
48  char msg[99];
49  sprintf_s(msg, sizeof(msg), "------%s------", caption);
50  logger->Log(msg);
51  sprintf_s(msg, sizeof(msg), "Min: %f", fm_min);
52  logger->Log(msg);
53  sprintf_s(msg, sizeof(msg), "Max: %f", fm_max);
54  logger->Log(msg);
55  sprintf_s(msg, sizeof(msg), "Avg: %f", fm_avg / fm_count);
56  logger->Log(msg);
57  sprintf_s(msg, sizeof(msg), "Frame Move Running on %f FPS avg", (1.0f / (fm_avg / fm_count)));
58  logger->Log(msg);
59 }
Logger * logger
Definition: performance.h:15
Definition: Logger.h:9
CStopWatch(Logger *prmLogger)
Definition: performance.cpp:4
double fm_max
Definition: performance.h:18
void Report(const char *caption) const
Definition: performance.cpp:46
LARGE_INTEGER stop
Definition: performance.h:23
LARGE_INTEGER start
Definition: performance.h:22
double fm_avg
Definition: performance.h:19
void stopTimer()
Definition: performance.cpp:27
LARGE_INTEGER frequency
Definition: performance.h:24
void Log(const char *msg, Level level=Info, int errorCode=0)
Definition: Logger.cpp:11
unsigned int fm_count
Definition: performance.h:20
void startTimer()
Definition: performance.cpp:22
double LIToSecs(LARGE_INTEGER &L)
Definition: performance.cpp:17
double fm_min
Definition: performance.h:17
void getElapsedTime()
Definition: performance.cpp:33