Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 471637
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T00:00:21+00:00 2026-05-13T00:00:21+00:00

It never happened to me. In Visual Studio, I have a part of code

  • 0

It never happened to me. In Visual Studio, I have a part of code that is executed 300 times, I time it every iteration with the performance counter, and then average it.
If I’m running the code in the debugger I get an average of 1.01 ms if I run it without the debugger I get 1.8 ms.

I closed all other apps, I rebooted, I tried it many times: Always the same timing.

I’m trying to optimize my code, but before throwing me into changing the code, I want to be sure of my timings. To have something to compare with.

What can cause that strange behaviour?

Edit:

Some clarification:

I’m running the same compiled piece of code: the release build. The only difference is (F5 vs CTRL-F5)
So, the compiler optimization should not be invoved.

Since each calcuated times were verry small, I changed the way I benchmark: I’m now timing the 300 iterations and then divide by 300. I have the same result.

About caching: The code is doing some image cross correlation, with different images at each iterations. The steps of the processing are not modified by the data in the images. So, I think caching is not the problem.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T00:00:21+00:00Added an answer on May 13, 2026 at 12:00 am

    I think I figured it out.

    If I add a Sleep(3000) before running the tests, they give the same result.

    I think it has something to do with the loading of misc. dlls. In the debugger, the dlls were loaded before any code was executed. Outside the debugger, the dlls were loaded on demand, and one or more were loaded after the timer was started.

    Thanks all.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

It happens quite frequently, more times per day, that with Visual Studio 2010 ,
I have never hand-coded object creation code for SQL Server and foreign key decleration
I have been using Visual Studio integrated with Source Safe for years, when I
This has never happened before. Never have I seen ANY of these warnings. There
So I have this problem, which has never happened to me before. I am
This has happened many times before, but I never bothered to figure out why,
Never used a cache like this before. The problem is that I want to
I never actually thought I'd run into speed-issues with python, but I have. I'm
I have never worked with web services and rails, and obviously this is something
In a Visual Studio project (C#), I attempted to perform a rename of a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.