Frame Rate in my Programm

I want to measure the frame rate of my program, Open GL and C++.

If the programm starts it should begin counting - if it ends it should stop counting. I need the time from the “start to the end”.

Is there an easy way to do it?

Thanks.

There are two basic ways to find out what time is it: you can use Win32 API or you can use standart C++ functions.
I prefer standart functions, because this way is “more portable”. To use those functions you must
#include <time.h>
Then to obtain current time use
long clock();
This function gives time in “ticks” (or “clocks”), so to translate it into seconds use constant CLOCKS_PER_SEC like this:
long time_in_clocks = clock();
float time_in_secs = (float)time_in_clocks/CLOCKS_PER_SEC;
To measure frames per second I use two static variable last_sec_time equal to the clock() whitch was a second ago, and frames_sinse_last_sec equal to the count of frames, whitch passed sinse last update of last_sec_time. Each frame I use next code:

long time = clock();
frames_sinse_last_sec ++;
if (last_sec_time - time > CLOCKS_PER_SEC)
{
    fps = (float)frames_sinse_last_sec/(last_sec_time - time);
    last_sec_time = time;
}

Variable float fps gives me the frames per second rate.