Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Time algorithms C++ ?  (Read 12049 times)

0 Members and 1 Guest are viewing this topic.

Redee

  • Jr. Member
  • **
  • Posts: 97
    • View Profile
Re: Time algorithms C++ ?
« Reply #15 on: November 26, 2014, 01:13:18 pm »
Ok I understand, thank you.

Yes I newbie but there says to minimal use in game!
>>
http://msdn.microsoft.com/en-us/library/windows/desktop/ee417693.aspx
Quote
Nevertheless, developers should attempt to have their games call QueryPerformanceCounter as little as possible to avoid any performance penalty.

Yes now I know need only 1 call, alright, no problem with QPC now )).

timeGetTime() and GetTickCount() as old reliable solution to measure time.
Else this needs link Winmm.lib (if you instal MS Visual Studio can find at C:\Program Files\Microsoft SDKs)
And at windows system32(64) path will be Winmm.dll
For example its using famous old game Quake3.
« Last Edit: November 29, 2014, 07:34:45 pm by Redee »

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Time algorithms C++ ?
« Reply #16 on: November 28, 2014, 02:43:24 am »
http://msdn.microsoft.com/en-us/library/windows/desktop/ee417693.aspx
Quote
Nevertheless, developers should attempt to have their games call QueryPerformanceCounter as little as possible to avoid any performance penalty.

Quote
can be called several hundred times per frame without any noticeable impact
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

Redee

  • Jr. Member
  • **
  • Posts: 97
    • View Profile
Re: Time algorithms C++ ?
« Reply #17 on: November 29, 2014, 02:55:59 pm »
timeGetTime() faster but no need thats amount of calls ))
Simple test >
(click to show/hide)
« Last Edit: November 29, 2014, 07:23:34 pm by Redee »

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Time algorithms C++ ?
« Reply #18 on: November 29, 2014, 03:24:53 pm »
What's your point? Which time measurement technique you use depends on the needed resolution...
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Redee

  • Jr. Member
  • **
  • Posts: 97
    • View Profile
Re: Time algorithms C++ ?
« Reply #19 on: November 29, 2014, 07:15:22 pm »
Nexus thank you, your advices very helpful.

In main game logic - I have global gameTimeCounter variable which refresh every frame.
All objects compare with this variable.
If more then minimal value after comparison - object do my action.

timeGetTime() is faster.
QPC is much more powerful but have some bugs.

I again here and very sorry - on old windows systems can be bugs with QPC.
http://msdn.microsoft.com/en-us/library/windows/desktop/dn553408.aspx

Quote
Windows XP and Windows 2000

QPC is available on Windows XP and Windows 2000 and works well on most systems. However, some hardware systems' BIOS didn't indicate the hardware CPU characteristics correctly (a non-invariant TSC), and some multi-core or multi-processor systems used processors with TSCs that couldn't be synchronized across cores. Systems with flawed firmware that run these versions of Windows might not provide the same QPC reading on different cores if they used the TSC as the basis for QPC.

Here also explains about possible issues.
http://www.virtualdub.org/blog/pivot/entry.php?id=106
(click to show/hide)

And here a little bit explains about bugs of QPC.
http://stackoverflow.com/questions/14363398/queryperformance-counter-in-multicore-systems-with-variable-clock-speeds

Who can use new vers. of MSVS (from 2012 and higher) - use <chrono> library for time measure.
If develop on old visual studio for old windows versions also - my advice use timeGetTime().

« Last Edit: November 30, 2014, 10:32:08 pm by Redee »