在Android的JNI高precision计时器 [英] High-precision timer in Android JNI

查看:573
本文介绍了在Android的JNI高precision计时器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想简介我的JNI应用程序。有没有像自启动以来得到滴答,我可以用它来衡量功能和/或系统?任何以毫秒会做的1/10 precision。

I'm trying to profile my JNI application. Is there something like "Get ticks since startup" that I can use to measure functions and/or systems? Anything with the precision of 1/10 of a millisecond will do.

显然,一个完全原生的功能会更好,我想preFER不是调用Java功能,每一件事情我想配置文件,但如果这是唯一的选择,我会带太

Obviously, a fully native function would be nicer, I'd prefer not to call a Java function for every single thing I'm trying to profile, but if that's the only option, I'll take that too.

推荐答案

clock_gettime()。你会看到样品code在Android的NDK-R5B /样本/你好氖/ JNI / helloneon.c和android-NDK-R5B /样本/原生浆/ JNI / plasma.c。

clock_gettime(). You'll see sample code in android-ndk-r5b/samples/hello-neon/jni/helloneon.c and android-ndk-r5b/samples/native-plasma/jni/plasma.c.

您想寻找类似CLOCK_MONOTONIC,以确保你得到蜱自启动,而不是墙上的挂钟。

You want to look for something like CLOCK_MONOTONIC to make sure you're getting ticks since startup, not the wall clock.

这篇关于在Android的JNI高precision计时器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆