Timer in Android JNI

I need a high res timer in my JNI code. OpenGL has it glutTimerFunc, but it looks like it is not available on Android.

Any suggestions?

+3
source share
1 answer

You can use C ++ 11 functions in jni. For example, Chrono:

std::high_resolution_clock::time_point t1 = std::chrono::high_resolution_clock::now();
{
    // Your code here
}
std::high_resolution_clock::time_point t2 = std::chrono::high_resolution_clock::now();

int duration = std::chrono::duration_cast<std::chrono::nanoseconds>(t2-t1).count();

or any other type of time from http://en.cppreference.com/w/cpp/chrono/duration

+1
source

All Articles