# Debug version is 10x faster than Release version?

**URL:** <https://forums.developer.nvidia.com/t/debug-version-is-10x-faster-than-release-version/2919>\
**Category:** CUDA Programming and Performance\
**Created:** [March 7, 2008, 2:52am UTC](https://forums.developer.nvidia.com/t/debug-version-is-10x-faster-than-release-version/2919 "2008-03-07T02:52:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sunafets](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@sunafets](https://forums.developer.nvidia.com/u/sunafets)\
**Post date:** [March 7, 2008, 2:52am UTC](https://forums.developer.nvidia.com/t/debug-version-is-10x-faster-than-release-version/2919/1 "2008-03-07T02:52:26Z")

</div>

I am new to CUDA, so please bear with me. I played around with some example projects from CUDA SDK, and I modified the template project to do simple 2D memory allocation and copy. I attach the code with this post. The puzzling thing is, cutil’s timer shows that the code runs faster when it is compiled on Debug mode!

On my Xeon 2.6GHz CPU with Quadro FX 4600, the attached code runs in less than 1ms in debug mode, but in release mode, it runs in \>10ms! I have run the code multiple times on both configurations. Could anyone tell me why is this so? Thanks.  
[Test.zip](https://forums.developer.nvidia.com/uploads/short-url/mZj8EU2krK6ouVwTSnubA2H0tkU.zip) (35.7 KB)

---

<div class="post-metadata">

**Author:** ![MisterAnderson42](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@MisterAnderson42](https://forums.developer.nvidia.com/u/MisterAnderson42)\
**Post date:** [March 7, 2008, 2:18pm UTC](https://forums.developer.nvidia.com/t/debug-version-is-10x-faster-than-release-version/2919/2 "2008-03-07T14:18:39Z")

</div>

1. You are only timing one iteration. To get accurate timing results you should perform many (hundreds to thousands) of measurements and average.

2. You are timing memory allocations. I don’t know of any specific reason why they would be different in release and debug modes, but are you truly trying to benchmark allocations? Memory allocations are likely to take widely different times to complete based on the currently allocated memory pool. And memory allocations are slow, you wouldn’t want to do them in the inner loop of your program.

3. By debug mode do you mean “Debug” or “EmuDebug”?? That could make the difference.

---

<div class="post-metadata">

**Author:** ![sunafets](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@sunafets](https://forums.developer.nvidia.com/u/sunafets)\
**Post date:** [March 10, 2008, 6:27am UTC](https://forums.developer.nvidia.com/t/debug-version-is-10x-faster-than-release-version/2919/3 "2008-03-10T06:27:31Z")

</div>

You’re right MrAnderson! After I perform thousands of iterations and average the timing, I get saner result. Previously, I observed that whenever I switch to Release mode and run the program (once), the timing always increased, and it decreased after I switch to Debug mode, hence my erroneous conclusion. Thanks.
