Skip to content

Commit a41cc9b

Browse files
committed
Add a timing log to Downsample for when decodes complete.
1 parent 3650c4e commit a41cc9b

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

library/src/main/java/com/bumptech/glide/load/resource/bitmap/Downsampler.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import com.bumptech.glide.load.resource.bitmap.DownsampleStrategy.SampleSizeRounding;
2020
import com.bumptech.glide.request.RequestOptions;
2121
import com.bumptech.glide.request.target.Target;
22+
import com.bumptech.glide.util.LogTime;
2223
import com.bumptech.glide.util.Preconditions;
2324
import com.bumptech.glide.util.Util;
2425
import java.io.IOException;
@@ -216,6 +217,7 @@ private Bitmap decodeFromWrappedStreams(InputStream is,
216217
DecodeFormat decodeFormat, boolean isHardwareConfigAllowed, int requestedWidth,
217218
int requestedHeight, boolean fixBitmapToRequestedDimensions,
218219
DecodeCallbacks callbacks) throws IOException {
220+
long startTime = LogTime.getLogTime();
219221

220222
int[] sourceDimensions = getDimensions(is, options, callbacks, bitmapPool);
221223
int sourceWidth = sourceDimensions[0];
@@ -278,7 +280,7 @@ && shouldUsePool(is)) {
278280

279281
if (Log.isLoggable(TAG, Log.VERBOSE)) {
280282
logDecode(sourceWidth, sourceHeight, sourceMimeType, options, downsampled,
281-
requestedWidth, requestedHeight);
283+
requestedWidth, requestedHeight, startTime);
282284
}
283285

284286
Bitmap rotated = null;
@@ -518,15 +520,17 @@ private static boolean isScaling(BitmapFactory.Options options) {
518520
}
519521

520522
private static void logDecode(int sourceWidth, int sourceHeight, String outMimeType,
521-
BitmapFactory.Options options, Bitmap result, int requestedWidth, int requestedHeight) {
523+
BitmapFactory.Options options, Bitmap result, int requestedWidth, int requestedHeight,
524+
long startTime) {
522525
Log.v(TAG, "Decoded " + getBitmapString(result)
523526
+ " from [" + sourceWidth + "x" + sourceHeight + "] " + outMimeType
524527
+ " with inBitmap " + getInBitmapString(options)
525528
+ " for [" + requestedWidth + "x" + requestedHeight + "]"
526529
+ ", sample size: " + options.inSampleSize
527530
+ ", density: " + options.inDensity
528531
+ ", target density: " + options.inTargetDensity
529-
+ ", thread: " + Thread.currentThread().getName());
532+
+ ", thread: " + Thread.currentThread().getName()
533+
+ ", duration: " + LogTime.getElapsedMillis(startTime));
530534
}
531535

532536
private static String getInBitmapString(BitmapFactory.Options options) {

library/src/main/java/com/bumptech/glide/util/LogTime.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public static long getLogTime() {
2424
if (Build.VERSION_CODES.JELLY_BEAN_MR1 <= Build.VERSION.SDK_INT) {
2525
return SystemClock.elapsedRealtimeNanos();
2626
} else {
27-
return System.currentTimeMillis();
27+
return SystemClock.uptimeMillis();
2828
}
2929
}
3030

0 commit comments

Comments
 (0)