The main problem could be that your drawing is done on GPU. You should call glFinish() before start and before end of measuring to ensure that CPU will wait for GPU. Otherwise you are not measuring drawing but only calls to GPU.
glFinish();
myTimer.start(); // initialized as QTime myTimer
DrawEverything();
glFinish();
int elapsed=myTimer.restart();
glFinish();
myTimer.start(); // initialized as QTime myTimer
DrawEverything();
glFinish();
int elapsed=myTimer.restart();
To copy to clipboard, switch view to plain text mode
As a multiplatform solution you can use Embedded Profiler (free for Windows and Linux) which has a higher resolution. It has an interface to timer in a processor cycle count units and can give you a number of cycles per seconds:
EProfilerTimer timer;
glFinish();
timer.Start();
... // your OpenGL code here
glFinish();
const uint64_t number_of_elapsed_cycles = timer.Stop();
const uint64_t nano_seconds_elapsed =
mumber_of_elapsed_cycles / (double) timer.GetCyclesPerSecond() * 1000000000;
EProfilerTimer timer;
glFinish();
timer.Start();
... // your OpenGL code here
glFinish();
const uint64_t number_of_elapsed_cycles = timer.Stop();
const uint64_t nano_seconds_elapsed =
mumber_of_elapsed_cycles / (double) timer.GetCyclesPerSecond() * 1000000000;
To copy to clipboard, switch view to plain text mode
Note:
Recalculation of cycle count to time is possibly a dangerous operation with modern processors where CPU frequency can be changed dynamically. Therefore to be sure that converted times are correct, it is necessary to fix processor frequency before profiling.
Bookmarks