我的 JNI 代码中需要一个高分辨率计时器。 OpenGL 中有 glutTimerFunc
,但它在 Android 上似乎不可用。
有什么建议吗?
最佳答案
您可以在 jni 中使用 c++11 函数。 例如计时:
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();
或来自 http://en.cppreference.com/w/cpp/chrono/duration 的任何其他时间类型
关于android - Android JNI 中的计时器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6274320/