diff options
author | Romain Guy <romainguy@google.com> | 2011-07-20 18:47:17 -0700 |
---|---|---|
committer | Romain Guy <romainguy@google.com> | 2011-07-20 18:47:17 -0700 |
commit | 648bee18a1ccd362445d562729250ff5910f16a0 (patch) | |
tree | 51fcdf0725beb8789d344e0ed85a5355674f6ddc /core/jni/android_os_SystemClock.cpp | |
parent | cf4cfc6fc88f204e2e496e37337f7e70809bbf6f (diff) | |
download | frameworks_base-648bee18a1ccd362445d562729250ff5910f16a0.zip frameworks_base-648bee18a1ccd362445d562729250ff5910f16a0.tar.gz frameworks_base-648bee18a1ccd362445d562729250ff5910f16a0.tar.bz2 |
Convert looper traces to traceview traces
Change-Id: If9238e8b00744118c1c4d2182727569f94deb638
Diffstat (limited to 'core/jni/android_os_SystemClock.cpp')
-rw-r--r-- | core/jni/android_os_SystemClock.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/core/jni/android_os_SystemClock.cpp b/core/jni/android_os_SystemClock.cpp index ffd0c1e..66d58cd 100644 --- a/core/jni/android_os_SystemClock.cpp +++ b/core/jni/android_os_SystemClock.cpp @@ -80,6 +80,38 @@ static jlong android_os_SystemClock_currentThreadTimeMillis(JNIEnv* env, } /* + * native public static long currentThreadTimeMicro(); + */ +static jlong android_os_SystemClock_currentThreadTimeMicro(JNIEnv* env, + jobject clazz) +{ +#if defined(HAVE_POSIX_CLOCKS) + struct timespec tm; + + clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tm); + + return tm.tv_sec * 1000000LL + tm.tv_nsec / 1000; +#else + struct timeval tv; + + gettimeofday(&tv, NULL); + return tv.tv_sec * 1000000LL + tv.tv_nsec / 1000; +#endif +} + +/* + * native public static long currentTimeMicro(); + */ +static jlong android_os_SystemClock_currentTimeMicro(JNIEnv* env, + jobject clazz) +{ + struct timeval tv; + + gettimeofday(&tv, NULL); + return tv.tv_sec * 1000000LL + tv.tv_usec; +} + +/* * JNI registration. */ static JNINativeMethod gMethods[] = { @@ -92,6 +124,10 @@ static JNINativeMethod gMethods[] = { (void*) android_os_SystemClock_elapsedRealtime }, { "currentThreadTimeMillis", "()J", (void*) android_os_SystemClock_currentThreadTimeMillis }, + { "currentThreadTimeMicro", "()J", + (void*) android_os_SystemClock_currentThreadTimeMicro }, + { "currentTimeMicro", "()J", + (void*) android_os_SystemClock_currentTimeMicro }, }; int register_android_os_SystemClock(JNIEnv* env) { |