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

Unified Diff: net/disk_cache/disk_cache_perftest.cc

Issue 2789683002: Speed up SimpleCache eviction set computation (Closed)
Patch Set: Created 3 years, 9 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 | « no previous file | net/disk_cache/simple/simple_index.h » ('j') | net/disk_cache/simple/simple_index.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/disk_cache/disk_cache_perftest.cc
diff --git a/net/disk_cache/disk_cache_perftest.cc b/net/disk_cache/disk_cache_perftest.cc
index eeef3b71d7363016b6e582d05b0e544cb22c6607..e3d3e7adaa0847e0c42a1c0f84205a37c6829a0c 100644
--- a/net/disk_cache/disk_cache_perftest.cc
+++ b/net/disk_cache/disk_cache_perftest.cc
@@ -27,6 +27,8 @@
#include "net/disk_cache/disk_cache_test_base.h"
#include "net/disk_cache/disk_cache_test_util.h"
#include "net/disk_cache/simple/simple_backend_impl.h"
+#include "net/disk_cache/simple/simple_index.h"
+#include "net/disk_cache/simple/simple_index_file.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/platform_test.h"
@@ -306,3 +308,33 @@ TEST_F(DiskCachePerfTest, BlockFilesPerformance) {
}
} // namespace
+
+namespace disk_cache {
+
+// Measures how quickly SimpleIndex can compute which entries to evict.
+TEST(SimpleIndexPerfTest, EvictionPerformance) {
+ class NoOpDelegate : public disk_cache::SimpleIndexDelegate {
+ void DoomEntries(std::vector<uint64_t>* entry_hashes,
+ const net::CompletionCallback& callback) override {}
+ };
+
+ NoOpDelegate delegate;
+ disk_cache::SimpleIndex index(nullptr, &delegate, net::DISK_CACHE, nullptr);
+
+ base::ElapsedTimer timer;
+ const int kEntries = 25000;
+ base::Time now(base::Time::Now());
+ index.SetMaxSize(kEntries);
+
+ for (int i = 0; i < kEntries; ++i) {
+ disk_cache::SimpleIndex::InsertInEntrySet(
+ i, disk_cache::EntryMetadata(now + base::TimeDelta::FromSeconds(i), 0u),
+ &index.entries_set_);
+ // Will trigger eviction once we are nearly full.
+ index.UpdateEntrySize(i, 1u);
+ }
+
+ LOG(ERROR) << "Took:" << timer.Elapsed().InMillisecondsF() << "ms";
pasko 2017/03/31 17:41:56 How stable are the numbers produced? I think it i
Maks Orlovich 2017/03/31 19:01:29 Less stable now that you've asked about it :) (usu
pasko 2017/04/03 09:39:08 Reasons I can see: 1. with const iterations there
+}
+
+} // namespace disk_cache
« no previous file with comments | « no previous file | net/disk_cache/simple/simple_index.h » ('j') | net/disk_cache/simple/simple_index.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698