From 1ebc7ebb84245b76d43a6779c65716e83051fe9c Mon Sep 17 00:00:00 2001 From: Nick Hurley Date: Sun, 30 Oct 2011 15:39:53 +0100 Subject: [PATCH] Bug 687081 - Time how long it takes to find (or not) things in the cache. r=jduell --- netwerk/cache/nsCacheService.cpp | 2 ++ netwerk/cache/nsDiskCacheDevice.cpp | 1 + netwerk/cache/nsDiskCacheDeviceSQL.cpp | 2 ++ netwerk/cache/nsMemoryCacheDevice.cpp | 2 ++ toolkit/components/telemetry/TelemetryHistograms.h | 4 ++++ 5 files changed, 11 insertions(+) diff --git a/netwerk/cache/nsCacheService.cpp b/netwerk/cache/nsCacheService.cpp index 30ac953885b..8af611f74fc 100644 --- a/netwerk/cache/nsCacheService.cpp +++ b/netwerk/cache/nsCacheService.cpp @@ -74,6 +74,7 @@ #include // for log() #include "mozilla/Util.h" // for DebugOnly #include "mozilla/Services.h" +#include "mozilla/Telemetry.h" #include "mozilla/FunctionTimer.h" @@ -1764,6 +1765,7 @@ nsCacheService::ActivateEntry(nsCacheRequest * request, nsCacheEntry * nsCacheService::SearchCacheDevices(nsCString * key, nsCacheStoragePolicy policy, bool *collision) { + Telemetry::AutoTimer timer; nsCacheEntry * entry = nsnull; CACHE_LOG_DEBUG(("mMemoryDevice: 0x%p\n", mMemoryDevice)); diff --git a/netwerk/cache/nsDiskCacheDevice.cpp b/netwerk/cache/nsDiskCacheDevice.cpp index 9b1cb797930..1fe79f29e68 100644 --- a/netwerk/cache/nsDiskCacheDevice.cpp +++ b/netwerk/cache/nsDiskCacheDevice.cpp @@ -503,6 +503,7 @@ nsDiskCacheDevice::GetDeviceID() nsCacheEntry * nsDiskCacheDevice::FindEntry(nsCString * key, bool *collision) { + Telemetry::AutoTimer timer; if (!Initialized()) return nsnull; // NS_ERROR_NOT_INITIALIZED nsDiskCacheRecord record; nsDiskCacheBinding * binding = nsnull; diff --git a/netwerk/cache/nsDiskCacheDeviceSQL.cpp b/netwerk/cache/nsDiskCacheDeviceSQL.cpp index 3ec77c2058a..38581ada84f 100644 --- a/netwerk/cache/nsDiskCacheDeviceSQL.cpp +++ b/netwerk/cache/nsDiskCacheDeviceSQL.cpp @@ -68,6 +68,7 @@ #include "nsISeekableStream.h" #include "mozilla/FunctionTimer.h" +#include "mozilla/Telemetry.h" using namespace mozilla; @@ -1340,6 +1341,7 @@ nsOfflineCacheDevice::GetDeviceID() nsCacheEntry * nsOfflineCacheDevice::FindEntry(nsCString *fullKey, bool *collision) { + mozilla::Telemetry::AutoTimer timer; LOG(("nsOfflineCacheDevice::FindEntry [key=%s]\n", fullKey->get())); // SELECT * FROM moz_cache WHERE key = ? diff --git a/netwerk/cache/nsMemoryCacheDevice.cpp b/netwerk/cache/nsMemoryCacheDevice.cpp index 64a5725f3ce..a53c731b733 100644 --- a/netwerk/cache/nsMemoryCacheDevice.cpp +++ b/netwerk/cache/nsMemoryCacheDevice.cpp @@ -48,6 +48,7 @@ #include "nsCRT.h" #include "nsCache.h" #include "nsReadableUtils.h" +#include "mozilla/Telemetry.h" // The memory cache implements the "LRU-SP" caching algorithm // described in "LRU-SP: A Size-Adjusted and Popularity-Aware LRU Replacement @@ -146,6 +147,7 @@ nsMemoryCacheDevice::GetDeviceID() nsCacheEntry * nsMemoryCacheDevice::FindEntry(nsCString * key, bool *collision) { + mozilla::Telemetry::AutoTimer timer; nsCacheEntry * entry = mMemCacheEntries.GetEntry(key); if (!entry) return nsnull; diff --git a/toolkit/components/telemetry/TelemetryHistograms.h b/toolkit/components/telemetry/TelemetryHistograms.h index 61c866dd87b..4552c5697ad 100644 --- a/toolkit/components/telemetry/TelemetryHistograms.h +++ b/toolkit/components/telemetry/TelemetryHistograms.h @@ -162,6 +162,10 @@ HISTOGRAM(HTTP_CACHE_DISPOSITION, 1, 5, 5, LINEAR, "HTTP Cache Hit, Reval, Faile HISTOGRAM(HTTP_DISK_CACHE_DISPOSITION, 1, 5, 5, LINEAR, "HTTP Disk Cache Hit, Reval, Failed-Reval, Miss") HISTOGRAM(HTTP_MEMORY_CACHE_DISPOSITION, 1, 5, 5, LINEAR, "HTTP Memory Cache Hit, Reval, Failed-Reval, Miss") HISTOGRAM(HTTP_OFFLINE_CACHE_DISPOSITION, 1, 5, 5, LINEAR, "HTTP Offline Cache Hit, Reval, Failed-Reval, Miss") +HISTOGRAM(CACHE_DEVICE_SEARCH, 1, 100, 100, LINEAR, "Time to search cache (ms)") +HISTOGRAM(CACHE_MEMORY_SEARCH, 1, 100, 100, LINEAR, "Time to search memory cache (ms)") +HISTOGRAM(CACHE_DISK_SEARCH, 1, 100, 100, LINEAR, "Time to search disk cache (ms)") +HISTOGRAM(CACHE_OFFLINE_SEARCH, 1, 100, 100, LINEAR, "Time to search offline cache (ms)") HISTOGRAM(FIND_PLUGINS, 1, 3000, 10, EXPONENTIAL, "Time spent scanning filesystem for plugins (ms)") HISTOGRAM(CHECK_JAVA_ENABLED, 1, 3000, 10, EXPONENTIAL, "Time spent checking if Java is enabled (ms)")