Search Home Members Contacts
About Us
Products
Downloads
Community
Support
Pages: [1]
  Print  
Author Topic: A common mistake with AccurateTimeElapsed()  (Read 417 times)
Lenn
Customers
Community Member
*****
Posts: 454

Ivan Miskelic


« on: August 05, 2008, 10:35:32 AM »

I've seen a few threads asking about why AccurateTimeElapsed seems to not give accurate values. I read through some of the replies and most often people seem to forget to advise on one first, most basic thing. Wink

AccurateTimeElapsed returns a SINGLE not an INTEGER value.

If you have it return the time elapsed to an integer variable, it will simply round it up or down, and the decimal part is very important in keeping accurate time. Otherwise, each rounding adds or substracts a little bit of time and you get wrong results.

I just thought I'd post this here instead of several old threads where I've found these problems without proper advice given.
Logged

NetLizard
Community Member
*
Posts: 162

If you know then show the code.


« Reply #1 on: September 28, 2008, 05:03:01 AM »

Floating-point division(decimal remainder)
------>  / Foward slash <--------


Integer division ( No remainder )
------->  \ Backslash <----------

Logged

If you know then show the code.
Mietze
Community Member
*
Posts: 277

Pleeease, don't let it crash!


WWW
« Reply #2 on: September 28, 2008, 06:08:18 AM »

Also keep in mind that this is not accurate all the time. This will return the time difference between two RenderToScreen(). If you have vertical synchronization activated or use multhithreading, it's better to use your own performance timer for this!
Logged

Check out my blog at www.e-studioz.de - The finest in gross trash Wink
TecnoBacon
Customers
Community Member
*****
Posts: 235


WWW
« Reply #3 on: September 28, 2008, 10:36:18 AM »

Just to note: it is almost twice as fast to multiply then divide in the proc, even if your storing a single for the multiply.
Logged

www.TecnoBacon.com - the other side of the Bacon family! 3D Development, Music and more.
Mietze
Community Member
*
Posts: 277

Pleeease, don't let it crash!


WWW
« Reply #4 on: September 28, 2008, 11:52:29 AM »

Just to note: it is almost twice as fast to multiply then divide in the proc, even if your storing a single for the multiply.
*nod*
Logged

Check out my blog at www.e-studioz.de - The finest in gross trash Wink
beyonder
Customers
Community Member
*****
Posts: 249


« Reply #5 on: September 28, 2008, 08:55:25 PM »

Quote
Just to note: it is almost twice as fast to multiply then divide in the proc, even if your storing a single for the multiply.

Why? Why? Why? I know this is true... I ran some tests and I believe its even faster than twice.

Sounds to me a division needs to be 'flipped' into a multiplication adding a few more steps to the process...

« Last Edit: September 28, 2008, 08:58:52 PM by beyonder » Logged
TecnoBacon
Customers
Community Member
*****
Posts: 235


WWW
« Reply #6 on: September 29, 2008, 08:25:04 AM »

Actually it has to do with addressing, a div is a multiply within the proc so several iterations are done to get the same result as a single mult would accomplish.
Logged

www.TecnoBacon.com - the other side of the Bacon family! 3D Development, Music and more.
Pages: [1]
  Print  
 
Jump to:  

Powered by SMF 1.1.3 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks