I think you will struggle to find a cross platform nanosecond measurement model.
Most people use GetTickCount64() to measure at the millisecond level.
Millisecond precision is not enough.If your program is running on a multitasking O/S, it is subject to whatever the scheduler decides to do. In such cases, even when the measurement is very precise, it is hard to say that it is representative of anything. Of course, you can take averages, drop large variations but, no matter what you do, the measurements, whatever they may be, will vary a great deal making them of questionable use.
Yes, that's why I have to use different functions on different platforms. Windows and Linux is done, macOS remained.Look epiktimer http://wiki.lazarus.freepascal.org/EpikTimer
If your program is running on a multitasking O/S, it is subject to whatever the scheduler decides to do. […]
Look epiktimer http://wiki.lazarus.freepascal.org/EpikTimer
But MacOS have precision time read https://developer.apple.com/library/archive/documentation/Darwin/Conceptual/KernelProgramming/services/services.html
If your program is running on a multitasking O/S, it is subject to whatever the scheduler decides to do. […]This is obvious, I know that and no, it does not bother me at all.
I need to get the time with nanosecond precision from the system to be able to measure the duration of the set of operations being performed (multiplatform project).It is obvious you will not get nanosecond precision - because the O/S scheduler is (obviously) going to get in the way.
It is obvious you will not get nanosecond precision - because the O/S scheduler is (obviously) going to get in the way.
Just for the record, in spite of the above, if I had an example of what you requested, I'd provide it to you.
Is it possible to use this function at all? Even indirectly?Example stackoverflow go language wrapper. Is no system function.
I not sure help you furious programmer... i sorry if not help.
http://nadeausoftware.com/articles/2012/04/c_c_tip_how_measure_elapsed_real_time_benchmarking
I hope that the problem is solved due to the "discovery" of the FPGetTimeOfDay function.
Sure, here you have: ...
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 (https://forum.lazarus.freepascal.org/index.php/topic,44908.msg318476.html#msg318476). If you want, download it and see what the whole timer code looks like.