开发者

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

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜