# Timing Calculations for Opengl ES 2.0 draw calls

I am drawing a cube in OpenGL ES 2.0 in Linux. I am calculating the time taken for each frame using below function

#define NANO 1000000000

#define NANO_TO_MICRO(x) ((x)/1000)

uint64_t getTick()
{
struct timespec stCT;
clock_gettime(CLOCK_MONOTONIC, &stCT);
uint64_t iCurrTimeNano = (1000000000 * stCT.tv_sec + stCT.tv_nsec); // in Nano Secs
uint64_t iCurrTimeMicro = NANO_TO_MICRO(iCurrTimeNano); // in Micro Secs

return iCurrTimeMicro;
}


I am running my code for 100 frames with simple x-axis rotation. I am getting around 200 to 220 microsecs per frame.

that means am i getting around (1/220microsec = 4545) FPS Is my GPU is that fast? I strongly doubt this result.

what went wrong in the code?

• after including eglswapbuffers for time calculations, my fps comes with 50 to 60. Why eglswapbuffers is taking more than 90% of my frame time ? – Arun AC Dec 13 '13 at 8:23

Are you calling glFinish() after each render pass? That call makes sure that the GPU has actually finished working. OpenGL calls submit the data/command to the GPU and return.
Otherwise, depending on the particulars of your rendering code and the GPU you have, you may get to those figures. Use glxgears and see if the values it reports are around your FPS.