Use nanoTime for elapsed time

This commit is contained in:
Sean Owen 2019-02-10 17:46:32 -06:00
parent fc5774ff13
commit 096cae7fcb

View file

@ -33,6 +33,7 @@ import android.util.Log;
import java.io.ByteArrayOutputStream;
import java.util.Map;
import java.util.concurrent.TimeUnit;
final class DecodeHandler extends Handler {
@ -73,7 +74,7 @@ final class DecodeHandler extends Handler {
* @param height The height of the preview frame.
*/
private void decode(byte[] data, int width, int height) {
long start = System.currentTimeMillis();
long start = System.nanoTime();
Result rawResult = null;
PlanarYUVLuminanceSource source = activity.getCameraManager().buildLuminanceSource(data, width, height);
if (source != null) {
@ -90,8 +91,8 @@ final class DecodeHandler extends Handler {
Handler handler = activity.getHandler();
if (rawResult != null) {
// Don't log the barcode contents for security.
long end = System.currentTimeMillis();
Log.d(TAG, "Found barcode in " + (end - start) + " ms");
long end = System.nanoTime();
Log.d(TAG, "Found barcode in " + TimeUnit.NANOSECONDS.toMillis(end - start) + " ms");
if (handler != null) {
Message message = Message.obtain(handler, R.id.decode_succeeded, rawResult);
Bundle bundle = new Bundle();