Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(838)

Unified Diff: Source/core/fetch/ResourceFetcher.cpp

Issue 148323002: Add histograms to ResourceFetcher to evaluate memory cache hit rate (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@histogram-unload-frequency
Patch Set: Addressed nits Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/fetch/ResourceFetcher.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/fetch/ResourceFetcher.cpp
diff --git a/Source/core/fetch/ResourceFetcher.cpp b/Source/core/fetch/ResourceFetcher.cpp
index ea44911232428333aea6d34d69eedae383194cb6..4e974f06854b9b92f5515fb42b8a3cb495d1cc67 100644
--- a/Source/core/fetch/ResourceFetcher.cpp
+++ b/Source/core/fetch/ResourceFetcher.cpp
@@ -635,6 +635,9 @@ ResourcePtr<Resource> ResourceFetcher::requestResource(Resource::Type type, Fetc
if (!resource)
return 0;
+ if (!resource->hasClients())
+ m_deadStatsRecorder.update(policy);
+
if (policy != Use)
resource->setIdentifier(createUniqueIdentifier());
@@ -1373,4 +1376,37 @@ const ResourceLoaderOptions& ResourceFetcher::defaultResourceOptions()
return options;
}
+ResourceFetcher::DeadResourceStatsRecorder::DeadResourceStatsRecorder()
+ : m_useCount(0)
+ , m_revalidateCount(0)
+ , m_loadCount(0)
+{
+}
+
+ResourceFetcher::DeadResourceStatsRecorder::~DeadResourceStatsRecorder()
+{
+ blink::Platform::current()->histogramCustomCounts(
+ "WebCore.ResourceFetcher.HitCount", m_useCount, 0, 1000, 50);
+ blink::Platform::current()->histogramCustomCounts(
+ "WebCore.ResourceFetcher.RevalidateCount", m_revalidateCount, 0, 1000, 50);
+ blink::Platform::current()->histogramCustomCounts(
+ "WebCore.ResourceFetcher.LoadCount", m_loadCount, 0, 1000, 50);
+}
+
+void ResourceFetcher::DeadResourceStatsRecorder::update(RevalidationPolicy policy)
+{
+ switch (policy) {
+ case Reload:
+ case Load:
+ ++m_loadCount;
+ return;
+ case Revalidate:
+ ++m_revalidateCount;
+ return;
+ case Use:
+ ++m_useCount;
+ return;
+ }
+}
+
}
« no previous file with comments | « Source/core/fetch/ResourceFetcher.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698