Search code examples
performancedelphifiremonkeydelphi-xe8

Multi-platform equivalent to QueryPerformanceCounter?


In Windows, I've used QueryPerformanceCounter to measure code performance in microseconds. I would like to do the same in all platforms within Firemonkey. I found one solution, but it's only for C++.

What's the equivalent for all platforms?


Solution

  • Use TStopwatch from System.Diagnostics.

    • On Windows it is implemented with QueryPerformanceCounter.
    • On Mac OS it is implemented with mach_absolute_time.
    • On POSIX platforms it is implemented with clock_gettime.