开发者

Timer in Android JNI

开发者 https://www.devze.com 2023-03-11 08:40 出处:网络
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.

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

0

精彩评论

暂无评论...
验证码 换一张
取 消