# Can I use QueryPerformanceCounter to measure single draw or compute call performance?

I know I can use QueryPerformanceCounter for measure time for whole single frame. But can I when it comes to OpenGL draw or compute call?

I always assumed that, as on the diagram, CPU waits for GPU to finish so timer would measure approximate time or am I wrong?

As seen in code:

glBindVertexArray(vertexArrayObject);
timer->startCounter();
glDrawElements(GL_TRIANGLE_STRIP, indices.size(), GL_UNSIGNED_INT, 0);
glBindVertexArray(0);
estimatedRenderTime = timer->getCounter();


or

timer->startCounter();
glDispatchCompute(width, height, 1);
estimatedRenderTime = timer->getCounter();


Furthermore, even if it did include glFinish/glClientWaitSync/etc, there is no guarantee that the CPU time in any way relates to how much time the GPU spent processing it. glFinish might block on a mutex, thus ending the thread's timeslice. Which means that the thread will start up sometime after that mutex is released. How long after? Who knows, but your QueryPerformanceCounter call will include that time.
If you want to measure GPU time, you should use tools that actually measure GPU time. For example, timer queries. You bracket some commands with glBeginQuery(GL_TIME_ELAPSED, queryObject) and glEndQuery(GL_TIME_ELAPSED). Then you can read the result after some time has elapsed. Like maybe next frame.
And unlike glFinish, this will not absolutely murder your performance ;)