New API to get the system-level tick
Posted: Sun Mar 26, 2017 12:01 pm
Hi,
So it's quite hard to actually measure performance right now. It is possible to a certain degree, but it would be made much easier if you simply added a read-only .time/.os_tick attribute or function somewhere (like on .game) that simply returns the system-level tick.
See here for an example https://github.com/o-lim/luasystem/
To be exact, what I actually want is the monotime property of that library. Specifically, this is the code for their Linux/Win implementation (there's also a Mac one):
Then we could much more easily measure our addon codepaths and optimize accordingly.
Thank you.
So it's quite hard to actually measure performance right now. It is possible to a certain degree, but it would be made much easier if you simply added a read-only .time/.os_tick attribute or function somewhere (like on .game) that simply returns the system-level tick.
See here for an example https://github.com/o-lim/luasystem/
To be exact, what I actually want is the monotime property of that library. Specifically, this is the code for their Linux/Win implementation (there's also a Mac one):
Code: Select all
#ifdef _WIN32
WINBASEAPI ULONGLONG WINAPI GetTickCount64(VOID);
static double time_monotime(void) {
ULONGLONG ms = GetTickCount64();
return ms*1.0e-3;
}
#else
static double time_monotime(void) {
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
return ts.tv_sec + ts.tv_nsec*1.0e-9;
}
#endif
Thank you.