Timer in Android JNI
I need a high res timer in my JNI code. There is glutTimerFunc
in OpenGL but it looks like it i开发者_C百科s not available on Android.
Any suggestions?
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
精彩评论