parent
79f5e84409
commit
0443cd4b5f
@ -0,0 +1,8 @@
|
||||
set(perfcheckers_source_files
|
||||
framerate.cpp
|
||||
framerate.hpp
|
||||
)
|
||||
MESSAGE(STATUS "Building perfcheckers")
|
||||
add_library(perfcheckers ${perfcheckers_source_files})
|
||||
|
||||
MESSAGE(STATUS "Done building perfcheckers")
|
@ -0,0 +1,19 @@
|
||||
#include "framerate.hpp"
|
||||
|
||||
void framerateChecker::tickBegin(){
|
||||
if(hasBegun) return;
|
||||
tBegin = std::time(0);
|
||||
hasBegun = true;
|
||||
tick = 0;
|
||||
fps = 0;
|
||||
}
|
||||
|
||||
void framerateChecker::tickUpdate(){
|
||||
frameCounter++;
|
||||
tEnd = std::time(0) - tBegin;
|
||||
|
||||
if(tEnd - tick < 1) return;
|
||||
tick++;
|
||||
fps = frameCounter;
|
||||
frameCounter = 0;
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
|
||||
#include <ctime>
|
||||
|
||||
class framerateChecker{
|
||||
private:
|
||||
bool hasBegun = false;
|
||||
|
||||
public:
|
||||
std::time_t tBegin, tEnd;
|
||||
int tick, fps = 0;
|
||||
long frameCounter = 0;
|
||||
|
||||
void tickBegin();
|
||||
void tickUpdate();
|
||||
};
|
Binary file not shown.
Loading…
Reference in new issue