I have the following code
static unsigned long long GetCurrentTimeInNanoseconds()
{
timespec t;
clock_gettime(CLOCK_MONOTONIC, &t);
return (unsigned long long)(t.tv_sec*1000000000ULL) + (unsigned long long)t.tv_nsec;
}
When I use it like this:
unsigned long long current = GetCurrentTimeInNanoseconds();
usleep(5000);
LOG_MESSAGE1( "sleep: %llu ns", GetCurrentTimeInNanoseconds() - current);
It prints this:
"sleep: 5126953 ns"
But if I use it like this:
current = GetCurrentTimeInNanoseconds();
glFinish();
LOG_MESSAGE1( "finish: %llu ns", GetCurrentTimeInNanoseconds() - current);
Then it prints:
"finish: 0 ns"
glFinish is a blocking call in opengl.. and when I change that one line of code in there my app slows down considerably. So how can it possibly take 0ns to do a glFinish on android? Can it be a nop? Otherwise does anyone see any problem with how I am getting the time or using the time?