Recent

Author Topic: [SOLVED] Getting the current time in form of nanoseconds count as Int64  (Read 2525 times)

ASBzone

  • Sr. Member
  • ****
  • Posts: 253
  • Automation leads to relaxation...
    • BrainWaveCC Utilities
Re: [SOLVED] Getting the current time in form of nanoseconds count as Int64
« Reply #30 on: April 22, 2019, 11:06:22 pm »
Sure, here you have:   ...

Thanks!  This thread caused me to read some seriously interesting articles today.   Thank you for this.
-ASB: https://www.BrainWaveCC.com

Lazarus v2.0.5 r62023 / FPC v3.2.0-beta-r43192 (via FpcUpDeluxe) -- Windows 64-bit install w/32-bit cross-compile
Primary System: Windows 10 Pro x64, Version 1903 (Build 18362.418)
Other Systems: Windows 10 Pro x64, Version 1903 or greater

furious programming

  • Sr. Member
  • ****
  • Posts: 354
  • I click a little.
Re: [SOLVED] Getting the current time in form of nanoseconds count as Int64
« Reply #31 on: April 23, 2019, 12:09:24 am »
Your welcome.

But my game is not a good example about how to use QPC, because it is used to build custom mechanism which work similar to FPNanoSleep but, instead of wait, it consumes all available CPU power. On Windows there is no solution to freeze the program for microseconds or nanoseconds — system Sleep function does not allow for this.

For clarity, the piece of code given in my previous post comes from the Platformer.Time.pp unit, and the sources of the entire project are available in this post. If you want, download it and see what the whole timer code looks like.
« Last Edit: May 07, 2019, 04:30:44 am by furious programming »
Lazarus 2.0.4 with FPC 3.0.4, Windows XP (all 32-bit)

ASBzone

  • Sr. Member
  • ****
  • Posts: 253
  • Automation leads to relaxation...
    • BrainWaveCC Utilities
Re: [SOLVED] Getting the current time in form of nanoseconds count as Int64
« Reply #32 on: April 23, 2019, 04:48:24 pm »
Your welcome.

But my game is not a good example about haw to use QPC, because it is used to build custom mechanism which work similar to FPNanoSleep but, instead of wait, it consumes all available CPU power. On Windows there is no solution to freeze the program for microseconds or nanoseconds — system Sleep function does not allow for this.

For clarity, the piece of code given in my previous post comes from the Platformer.Time.pp unit, and the sources of the entire project are available in this post. If you want, download it and see what the whole timer code looks like.

Thanks again.  I read several articles and pages, and was able to adapt it to my needs so that I could replace the following, which I had been using for tracking the passing of time.

Here's the source of what I had been using for some functions:  https://stackoverflow.com/questions/17109814/why-datetimetomilliseconds-in-dateutils-pas-is-marked-as-internal

For now, it is a Windows-only solution, but I will deal with cross-platform in due time.
-ASB: https://www.BrainWaveCC.com

Lazarus v2.0.5 r62023 / FPC v3.2.0-beta-r43192 (via FpcUpDeluxe) -- Windows 64-bit install w/32-bit cross-compile
Primary System: Windows 10 Pro x64, Version 1903 (Build 18362.418)
Other Systems: Windows 10 Pro x64, Version 1903 or greater