Skip to content

Commit

Permalink
Use nanoTime for elapsed time
Browse files Browse the repository at this point in the history
  • Loading branch information
srowen committed Feb 10, 2019
1 parent fc5774f commit 096cae7
Showing 1 changed file with 4 additions and 3 deletions.
Expand Up @@ -33,6 +33,7 @@

import java.io.ByteArrayOutputStream;
import java.util.Map;
import java.util.concurrent.TimeUnit;

final class DecodeHandler extends Handler {

Expand Down Expand Up @@ -73,7 +74,7 @@ public void handleMessage(Message message) {
* @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) {
Expand All @@ -90,8 +91,8 @@ private void decode(byte[] data, int width, int height) {
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();
Expand Down

0 comments on commit 096cae7

Please sign in to comment.