Jump to content

timeGetTime: identifier not found?


Josh
 Share

Recommended Posts

With the new timing, you can make your own accurate Sleep() function, which really sleeps for 1ms, and not 2.

 

Really? If you call a Sleep(2) then the counter increments by 3. Basically, how ever long you sleep for, the counter increment is going to be 1 + the sleep duration. It looks like if you're going to be processor-friendly then you'll have to stick with 2ms accuracy, but really, 2 isn't bad...

LE Version: 2.50 (Eventually)

Link to comment
Share on other sites

You can also call Sleep(0) for times below 2ms, and just make a while loop to check if the wanted time has elapsed.

It will still give CPU cycles to the OS, and work pretty nicely.

 

I've already made an abstract BaseApplication class, but I think I want to make it further cleaner C++, and make also an abstract Timer class.

 

What I also noticed is that Sleep() is not even accurate with higher values, like values of 100 or more, because it still keeps jumping between the wanted time, and +1ms.

But I found a solution for that problem also, which I implemented into my abstract class.

Basically you let Sleep() only do the wanted time-10ms, and sync the last 10ms yourself in your loop.

 

Sure, it will take a few cycles more CPU time, but since most users have a bloated Windows with more than 50 processes running anyway, it won't make any difference. I have only 14 processes running, and I even deleted (renamed) explorer.exe because it took like 5 minutes CPU time when booting. It's totally useless anyway, as Windows works fine with taskman.exe only ;)

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...