/* fps.cpp v 1.0; Michal Szabados */

#include <ctime>

clock_t fps_time_old = 0, fps_time_now = 0;
int fps_cframes = 0;
double fps_ret = -1;

double get_fps()
{
	fps_cframes++;

	fps_time_now = clock();

	if (fps_time_now-fps_time_old >= CLOCKS_PER_SEC)
	{
		fps_ret = (double) fps_cframes * (double) CLOCKS_PER_SEC / (double)(fps_time_now-fps_time_old);
		fps_time_old = fps_time_now;
		fps_cframes = 0;
	}

	return fps_ret;
}