Reputation: 578
I need a high res timer in my JNI code. There is glutTimerFunc
in OpenGL but it looks like it is not available on Android.
Any suggestions?
Upvotes: 3
Views: 903
Reputation: 386
You can use c++11 functions in jni. Chrono for example:
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 time type from http://en.cppreference.com/w/cpp/chrono/duration
Upvotes: 1