diff options
-rw-r--r-- | core/jni/android/graphics/TextLayoutCache.cpp | 14 | ||||
-rw-r--r-- | core/jni/android/graphics/TextLayoutCache.h | 2 |
2 files changed, 12 insertions, 4 deletions
diff --git a/core/jni/android/graphics/TextLayoutCache.cpp b/core/jni/android/graphics/TextLayoutCache.cpp index 77a731a..df017f5 100644 --- a/core/jni/android/graphics/TextLayoutCache.cpp +++ b/core/jni/android/graphics/TextLayoutCache.cpp @@ -126,11 +126,17 @@ sp<TextLayoutCacheValue> TextLayoutCache::getValue(SkPaint* paint, // Value not found for the key, we need to add a new value in the cache if (value == NULL) { + if (mDebugEnabled) { + startTime = systemTime(SYSTEM_TIME_MONOTONIC); + } + value = new TextLayoutCacheValue(); // Compute advances and store them value->computeValues(paint, text, start, count, contextCount, dirFlags); + nsecs_t endTime = systemTime(SYSTEM_TIME_MONOTONIC); + // Don't bother to add in the cache if the entry is too big size_t size = key.getSize() + value->getSize(); if (size <= mMaxSize) { @@ -155,7 +161,7 @@ sp<TextLayoutCacheValue> TextLayoutCache::getValue(SkPaint* paint, if (mDebugEnabled) { // Update timing information for statistics - value->setElapsedTime(systemTime(SYSTEM_TIME_MONOTONIC) - startTime); + value->setElapsedTime(endTime - startTime); LOGD("CACHE MISS: Added entry for text='%s' with start=%d, count=%d, " "contextCount=%d, entry size %d bytes, remaining space %d bytes" @@ -168,9 +174,9 @@ sp<TextLayoutCacheValue> TextLayoutCache::getValue(SkPaint* paint, LOGD("CACHE MISS: Calculated but not storing entry because it is too big " "for text='%s' with start=%d, count=%d, contextCount=%d, " "entry size %d bytes, remaining space %d bytes" - " - Compute time in nanos: %d", + " - Compute time in nanos: %lld", String8(text, contextCount).string(), start, count, contextCount, - size, mMaxSize - mSize, value->getElapsedTime()); + size, mMaxSize - mSize, endTime); } value.clear(); } @@ -205,7 +211,9 @@ void TextLayoutCache::dumpCacheStats() { LOGD("------------------------------------------------"); LOGD("TextLayoutCache stats"); LOGD("------------------------------------------------"); + LOGD("pid : %d", getpid()); LOGD("running : %.0f seconds", timeRunningInSec); + LOGD("entries : %d", mCache.size()); LOGD("size : %d bytes", mMaxSize); LOGD("remaining : %d bytes or %2.2f percent", mMaxSize - mSize, remainingPercent); LOGD("hits : %d", mCacheHitCount); diff --git a/core/jni/android/graphics/TextLayoutCache.h b/core/jni/android/graphics/TextLayoutCache.h index 62813df..690caac 100644 --- a/core/jni/android/graphics/TextLayoutCache.h +++ b/core/jni/android/graphics/TextLayoutCache.h @@ -53,7 +53,7 @@ #define MB(s) s * 1024 * 1024 // Define the default cache size in Mb -#define DEFAULT_TEXT_LAYOUT_CACHE_SIZE_IN_MB 0.125f +#define DEFAULT_TEXT_LAYOUT_CACHE_SIZE_IN_MB 0.250f // Define the interval in number of cache hits between two statistics dump #define DEFAULT_DUMP_STATS_CACHE_HIT_INTERVAL 100 |