Recent

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

ASBzone

  • Hero Member
  • *****
  • Posts: 678
  • Automation leads to relaxation...
    • Free Console Utilities for Windows (and a few for Linux) from BrainWaveCC
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.2.7-ada7a90186 / FPC v3.2.3-706-gaadb53e72c
(Windows 64-bit install w/Win32 and Linux/Arm cross-compiles via FpcUpDeluxe on both instances)

My Systems: Windows 10/11 Pro x64 (Current)

furious programming

  • Hero Member
  • *****
  • Posts: 852
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 3.2 with FPC 3.2.2, Windows 10 — all 64-bit

Working solo on an acrade, action/adventure game in retro style (pixelart), programming the engine and shell from scratch, using Free Pascal and SDL. Release planned in 2026.

ASBzone

  • Hero Member
  • *****
  • Posts: 678
  • Automation leads to relaxation...
    • Free Console Utilities for Windows (and a few for Linux) from BrainWaveCC
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.2.7-ada7a90186 / FPC v3.2.3-706-gaadb53e72c
(Windows 64-bit install w/Win32 and Linux/Arm cross-compiles via FpcUpDeluxe on both instances)

My Systems: Windows 10/11 Pro x64 (Current)

 

TinyPortal © 2005-2018