From be34314e1a1bfd9165698436766d65bd2161f1fe Mon Sep 17 00:00:00 2001 From: Walter Korman Date: Sat, 7 Dec 2002 01:00:58 +0000 Subject: [PATCH] Report image cache performance in all relevant places. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2032 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../threerings/media/image/ImageManager.java | 26 ++++++++++++++----- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/src/java/com/threerings/media/image/ImageManager.java b/src/java/com/threerings/media/image/ImageManager.java index bd491d060..db424f5b9 100644 --- a/src/java/com/threerings/media/image/ImageManager.java +++ b/src/java/com/threerings/media/image/ImageManager.java @@ -1,5 +1,5 @@ // -// $Id: ImageManager.java,v 1.28 2002/12/07 00:58:00 shaper Exp $ +// $Id: ImageManager.java,v 1.29 2002/12/07 01:00:58 shaper Exp $ package com.threerings.media; @@ -68,12 +68,7 @@ public class ImageManager } // periodically report our image cache performance - if (!_cacheStatThrottle.throttleOp()) { - int size = getCachedImageSize() / 1024; - int[] eff = _imgs.getTrackedEffectiveness(); - Log.debug("ImageManager LRU [size=" + size + "k pixels" + - ", hits=" + eff[0] + ", misses=" + eff[1] + "]."); - } + reportCachePerformance(); String key = rset + ":" + path; Image img = (Image)_imgs.get(key); @@ -125,6 +120,9 @@ public class ImageManager */ public Image getImage (String path) { + // periodically report our image cache performance + reportCachePerformance(); + Image img = (Image)_imgs.get(path); if (img != null) { // Log.info("Retrieved image from cache [path=" + path + "]."); @@ -150,6 +148,20 @@ public class ImageManager return img; } + /** + * Reports statistics detailing the image manager cache performance + * and the current size of the cached images. + */ + protected void reportCachePerformance () + { + if (!_cacheStatThrottle.throttleOp()) { + int size = getCachedImageSize() / 1024; + int[] eff = _imgs.getTrackedEffectiveness(); + Log.debug("ImageManager LRU [size=" + size + "k pixels" + + ", hits=" + eff[0] + ", misses=" + eff[1] + "]."); + } + } + /** * Loads the image via the resource manager using the specified * path. Does no caching and does not convert the image for optimized