Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

To measure CPU code, I use a Stopwatch. Using a Stopwatch in the Draw method is meaningless for the GPU side of things since the CPU and the GPU run asynchronously.

The questions is simple: Is it possible to measure the total time spent on a chunk of HLSL code? Perhaps as granular as the technique/pass.

share|improve this question
up vote 3 down vote accepted

You seem to be using DirectX, so you can probably use the techniques described in this article. It explains how to use ID3D11Query objects to profile GPU code.

Since you're in managed code, you might have to use some clever P/Invoke to get to that API if SharpDX doesn't expose the functions itself, although it seems like it does.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.