mirror of
https://github.com/zxing/zxing.git
synced 2024-09-20 05:27:32 -07:00
Use nanoTime for elapsed time
This commit is contained in:
parent
fc5774ff13
commit
096cae7fcb
|
@ -33,6 +33,7 @@ import android.util.Log;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
final class DecodeHandler extends Handler {
|
final class DecodeHandler extends Handler {
|
||||||
|
|
||||||
|
@ -73,7 +74,7 @@ final class DecodeHandler extends Handler {
|
||||||
* @param height The height of the preview frame.
|
* @param height The height of the preview frame.
|
||||||
*/
|
*/
|
||||||
private void decode(byte[] data, int width, int height) {
|
private void decode(byte[] data, int width, int height) {
|
||||||
long start = System.currentTimeMillis();
|
long start = System.nanoTime();
|
||||||
Result rawResult = null;
|
Result rawResult = null;
|
||||||
PlanarYUVLuminanceSource source = activity.getCameraManager().buildLuminanceSource(data, width, height);
|
PlanarYUVLuminanceSource source = activity.getCameraManager().buildLuminanceSource(data, width, height);
|
||||||
if (source != null) {
|
if (source != null) {
|
||||||
|
@ -90,8 +91,8 @@ final class DecodeHandler extends Handler {
|
||||||
Handler handler = activity.getHandler();
|
Handler handler = activity.getHandler();
|
||||||
if (rawResult != null) {
|
if (rawResult != null) {
|
||||||
// Don't log the barcode contents for security.
|
// Don't log the barcode contents for security.
|
||||||
long end = System.currentTimeMillis();
|
long end = System.nanoTime();
|
||||||
Log.d(TAG, "Found barcode in " + (end - start) + " ms");
|
Log.d(TAG, "Found barcode in " + TimeUnit.NANOSECONDS.toMillis(end - start) + " ms");
|
||||||
if (handler != null) {
|
if (handler != null) {
|
||||||
Message message = Message.obtain(handler, R.id.decode_succeeded, rawResult);
|
Message message = Message.obtain(handler, R.id.decode_succeeded, rawResult);
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
|
|
Loading…
Reference in a new issue