summaryrefslogtreecommitdiffstats
path: root/base/memory/mru_cache_unittest.cc
diff options
context:
space:
mode:
authorgcasto@chromium.org <gcasto@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-09 23:30:44 +0000
committergcasto@chromium.org <gcasto@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-09 23:30:44 +0000
commit5cf71c5f13a3dbabae77e519d5762ac5295a0de9 (patch)
treebbe4c1ec6f2819ca8f3ee1329ae56be4ab152314 /base/memory/mru_cache_unittest.cc
parent460e571ba4d40edd7fe22d378d82f73bf555fc57 (diff)
downloadchromium_src-5cf71c5f13a3dbabae77e519d5762ac5295a0de9.zip
chromium_src-5cf71c5f13a3dbabae77e519d5762ac5295a0de9.tar.gz
chromium_src-5cf71c5f13a3dbabae77e519d5762ac5295a0de9.tar.bz2
Optimize phishing page term feature extraction.
We've been seeing in the histograms that for some users, page feature extraction is taking much longer than we would like, up to 200ms between stops. This could possibly contribute to jankiness in the UI. These are some timings from my desktop for how long it takes to extract features before and after these changes. Obviously this is on much better hardware than the use case we are worried about, but hopefully the increase is speed is proportional. Before After CNN 19 7.5 ESPN 22 9.5 Google 12 4 Salon 40 12 BUG= TEST=Ran associated unit tests. Review URL: http://codereview.chromium.org/7549003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@96097 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/memory/mru_cache_unittest.cc')
-rw-r--r--base/memory/mru_cache_unittest.cc18
1 files changed, 18 insertions, 0 deletions
diff --git a/base/memory/mru_cache_unittest.cc b/base/memory/mru_cache_unittest.cc
index 89ca2fa..39677f2 100644
--- a/base/memory/mru_cache_unittest.cc
+++ b/base/memory/mru_cache_unittest.cc
@@ -251,3 +251,21 @@ TEST(MRUCacheTest, AutoEvict) {
// There should be no objects leaked.
EXPECT_EQ(initial_count, cached_item_live_count);
}
+
+TEST(MRUCacheTest, HashingMRUCache) {
+ // Very simple test to make sure that the hashing cache works correctly.
+ typedef base::HashingMRUCache<std::string, CachedItem> Cache;
+ Cache cache(Cache::NO_AUTO_EVICT);
+
+ CachedItem one(1);
+ cache.Put("First", one);
+
+ CachedItem two(2);
+ cache.Put("Second", two);
+
+ EXPECT_EQ(one.value, cache.Get("First")->second.value);
+ EXPECT_EQ(two.value, cache.Get("Second")->second.value);
+ cache.ShrinkToSize(1);
+ EXPECT_EQ(two.value, cache.Get("Second")->second.value);
+ EXPECT_EQ(cache.end(), cache.Get("First"));
+}