nmnir
nmnir

Reputation: 578

Timer in Android JNI

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

Answers (1)

Michele
Michele

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

Related Questions