mobile/android/thirdparty/com/squareup/picasso/StatsSnapshot.java

Wed, 31 Dec 2014 07:22:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:22:50 +0100
branch
TOR_BUG_3246
changeset 4
fc2d59ddac77
permissions
-rw-r--r--

Correct previous dual key logic pending first delivery installment.

michael@0 1 /*
michael@0 2 * Copyright (C) 2013 Square, Inc.
michael@0 3 *
michael@0 4 * Licensed under the Apache License, Version 2.0 (the "License");
michael@0 5 * you may not use this file except in compliance with the License.
michael@0 6 * You may obtain a copy of the License at
michael@0 7 *
michael@0 8 * http://www.apache.org/licenses/LICENSE-2.0
michael@0 9 *
michael@0 10 * Unless required by applicable law or agreed to in writing, software
michael@0 11 * distributed under the License is distributed on an "AS IS" BASIS,
michael@0 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
michael@0 13 * See the License for the specific language governing permissions and
michael@0 14 * limitations under the License.
michael@0 15 */
michael@0 16 package com.squareup.picasso;
michael@0 17
michael@0 18 import android.util.Log;
michael@0 19 import java.io.PrintWriter;
michael@0 20 import java.io.StringWriter;
michael@0 21
michael@0 22 /** Represents all stats for a {@link Picasso} instance at a single point in time. */
michael@0 23 public class StatsSnapshot {
michael@0 24 private static final String TAG = "Picasso";
michael@0 25
michael@0 26 public final int maxSize;
michael@0 27 public final int size;
michael@0 28 public final long cacheHits;
michael@0 29 public final long cacheMisses;
michael@0 30 public final long totalOriginalBitmapSize;
michael@0 31 public final long totalTransformedBitmapSize;
michael@0 32 public final long averageOriginalBitmapSize;
michael@0 33 public final long averageTransformedBitmapSize;
michael@0 34 public final int originalBitmapCount;
michael@0 35 public final int transformedBitmapCount;
michael@0 36
michael@0 37 public final long timeStamp;
michael@0 38
michael@0 39 public StatsSnapshot(int maxSize, int size, long cacheHits, long cacheMisses,
michael@0 40 long totalOriginalBitmapSize, long totalTransformedBitmapSize, long averageOriginalBitmapSize,
michael@0 41 long averageTransformedBitmapSize, int originalBitmapCount, int transformedBitmapCount,
michael@0 42 long timeStamp) {
michael@0 43 this.maxSize = maxSize;
michael@0 44 this.size = size;
michael@0 45 this.cacheHits = cacheHits;
michael@0 46 this.cacheMisses = cacheMisses;
michael@0 47 this.totalOriginalBitmapSize = totalOriginalBitmapSize;
michael@0 48 this.totalTransformedBitmapSize = totalTransformedBitmapSize;
michael@0 49 this.averageOriginalBitmapSize = averageOriginalBitmapSize;
michael@0 50 this.averageTransformedBitmapSize = averageTransformedBitmapSize;
michael@0 51 this.originalBitmapCount = originalBitmapCount;
michael@0 52 this.transformedBitmapCount = transformedBitmapCount;
michael@0 53 this.timeStamp = timeStamp;
michael@0 54 }
michael@0 55
michael@0 56 /** Prints out this {@link StatsSnapshot} into log. */
michael@0 57 public void dump() {
michael@0 58 StringWriter logWriter = new StringWriter();
michael@0 59 dump(new PrintWriter(logWriter));
michael@0 60 Log.i(TAG, logWriter.toString());
michael@0 61 }
michael@0 62
michael@0 63 /** Prints out this {@link StatsSnapshot} with the the provided {@link PrintWriter}. */
michael@0 64 public void dump(PrintWriter writer) {
michael@0 65 writer.println("===============BEGIN PICASSO STATS ===============");
michael@0 66 writer.println("Memory Cache Stats");
michael@0 67 writer.print(" Max Cache Size: ");
michael@0 68 writer.println(maxSize);
michael@0 69 writer.print(" Cache Size: ");
michael@0 70 writer.println(size);
michael@0 71 writer.print(" Cache % Full: ");
michael@0 72 writer.println((int) Math.ceil((float) size / maxSize * 100));
michael@0 73 writer.print(" Cache Hits: ");
michael@0 74 writer.println(cacheHits);
michael@0 75 writer.print(" Cache Misses: ");
michael@0 76 writer.println(cacheMisses);
michael@0 77 writer.println("Bitmap Stats");
michael@0 78 writer.print(" Total Bitmaps Decoded: ");
michael@0 79 writer.println(originalBitmapCount);
michael@0 80 writer.print(" Total Bitmap Size: ");
michael@0 81 writer.println(totalOriginalBitmapSize);
michael@0 82 writer.print(" Total Transformed Bitmaps: ");
michael@0 83 writer.println(transformedBitmapCount);
michael@0 84 writer.print(" Total Transformed Bitmap Size: ");
michael@0 85 writer.println(totalTransformedBitmapSize);
michael@0 86 writer.print(" Average Bitmap Size: ");
michael@0 87 writer.println(averageOriginalBitmapSize);
michael@0 88 writer.print(" Average Transformed Bitmap Size: ");
michael@0 89 writer.println(averageTransformedBitmapSize);
michael@0 90 writer.println("===============END PICASSO STATS ===============");
michael@0 91 writer.flush();
michael@0 92 }
michael@0 93
michael@0 94 @Override public String toString() {
michael@0 95 return "StatsSnapshot{"
michael@0 96 + "maxSize="
michael@0 97 + maxSize
michael@0 98 + ", size="
michael@0 99 + size
michael@0 100 + ", cacheHits="
michael@0 101 + cacheHits
michael@0 102 + ", cacheMisses="
michael@0 103 + cacheMisses
michael@0 104 + ", totalOriginalBitmapSize="
michael@0 105 + totalOriginalBitmapSize
michael@0 106 + ", totalTransformedBitmapSize="
michael@0 107 + totalTransformedBitmapSize
michael@0 108 + ", averageOriginalBitmapSize="
michael@0 109 + averageOriginalBitmapSize
michael@0 110 + ", averageTransformedBitmapSize="
michael@0 111 + averageTransformedBitmapSize
michael@0 112 + ", originalBitmapCount="
michael@0 113 + originalBitmapCount
michael@0 114 + ", transformedBitmapCount="
michael@0 115 + transformedBitmapCount
michael@0 116 + ", timeStamp="
michael@0 117 + timeStamp
michael@0 118 + '}';
michael@0 119 }
michael@0 120 }

mercurial