Android 记录代码执行时间

我们经常需要记录一段代码的执行时间,在Android中,一个非常简单的方法就是调用System.nanoTime();

long start_val = System.nanoTime();
float[] array = mActivity.getFaces(data, w, h);
long end_val = System.nanoTime();

Log.i(TAG, "Diff is " + (end_val - start_val));

这个是纳秒级的。

Keep Practising as Kobe does!
原文地址:https://www.cnblogs.com/lstj/p/3285286.html