头文件#include
这里计算的是10内/mytest运行多少次,来计算fps
int frameCount = 0;
auto startTime = std::chrono::high_resolution_clock::now();
while (true)
{
++frameCount;
............................................//mytest();
auto currentTime = std::chrono::high_resolution_clock::now();
auto elapsed = std::chrono::duration_cast<std::chrono::seconds>(currentTime - startTime);
if (elapsed.count() >= 10) {
double fps = static_cast<double>(frameCount) / elapsed.count();
std::cout << "FPS: " << fps << std::endl;
frameCount = 0;
startTime = currentTime;
}
}