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

  • SEARCH
  • Home
  • 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 3286076
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T20:20:21+00:00 2026-05-17T20:20:21+00:00

Last week I needed to test some different algorithmic functions and to make it

  • 0

Last week I needed to test some different algorithmic functions and to make it easy to myself I added some artifical sleeps and simply measured the clock time. Something like this:

start = clock();
for (int i=0;i<10000;++i)
   {
   ...
   Sleep(1);
   ...
   }
end = clock();

Since the argument of Sleep is expressed in milliseconds I expected a total wall clock time of about 10 seconds (a big higher because of the algorithms but that’s not important now), and that was indeed my result.

This morning I had to reboot my PC because of new Microsoft Windows hot fixes and to my surprise Sleep(1) didn’t take 1 millisecond anymore, but about 0.0156 seconds.

So my test results were completely screwed up, since the total time grew from 10 seconds to about 156 seconds.

We tested this on several PC’s and apparently on some PC’s the result of one Sleep was indeed 1 ms. On other PC’s it was 0.0156 seconds.

Then, suddenly, after a while, the time of Sleep dropped to 0.01 second, and then an hour later back to 0.001 second (1 ms).

Is this normal behavior in Windows?
Is Windows ‘sleepy’ the first hours after reboot and then gradually gets a higher sleep-granularity after a while?
Or are there any other aspects that might explain the change in behavior?

In all my tests no other application was running at the same time (or: at least not taking any CPU).

Any ideas?

OS is Windows 7.

  • 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-17T20:20:22+00:00Added an answer on May 17, 2026 at 8:20 pm

    I’ve not heard about the resolution jumping around like that on its own, but in general the resolution of Sleep follows the clock tick of the task scheduler. So by default it’s usually 10 or 15 ms, depending on the edition of Windows. You can set it manually to 1 ms by issuing a timeBeginPeriod.

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

Sidebar

Related Questions

I was writing some Unit tests last week for a piece of code that
Last week I started to write a script in Ruby. I needed to scrape
I read about sed last week and now, I do some extraction from a
Last week we released Omniture's analytics code onto a large volume of web sites
Last week I implemented a date validation in our front end, a combination of
The last week on the ACM ICPC Mexico competition, I missed a return 0
Given a week-day (1-7), how can I calculate what that week-day's last date was?
Last time I asked about the reverse process , and got some very efficient
Last night I added a parameter to a stored procedure in a mySQL database.
I posted this question last week, but I wasn't very clear on what was

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.