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

Unified Diff: net/disk_cache/disk_cache_perftest.cc

Issue 2789683002: Speed up SimpleCache eviction set computation (Closed)
Patch Set: git cl try 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') | no next file with comments »
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..e16cccb4fe41e53a501023b15ca3d878a5ca8742 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"
@@ -305,4 +307,42 @@ TEST_F(DiskCachePerfTest, BlockFilesPerformance) {
base::RunLoop().RunUntilIdle();
}
+// Measures how quickly SimpleIndex can compute which entries to evict.
+TEST(SimpleIndexPerfTest, EvictionPerformance) {
+ const int kEntries = 10000;
+
+ class NoOpDelegate : public disk_cache::SimpleIndexDelegate {
+ void DoomEntries(std::vector<uint64_t>* entry_hashes,
+ const net::CompletionCallback& callback) override {}
+ };
+
+ NoOpDelegate delegate;
+ base::Time start(base::Time::Now());
+
+ double evict_elapsed_ms = 0;
+ int iterations = 0;
+ while (iterations < 61000) {
+ ++iterations;
+ disk_cache::SimpleIndex index(nullptr, &delegate, net::DISK_CACHE, nullptr);
+
+ // Make sure large enough to not evict on insertion.
+ index.SetMaxSize(kEntries * 2);
+
+ for (int i = 0; i < kEntries; ++i) {
+ index.InsertEntryForTesting(
+ i, disk_cache::EntryMetadata(start + base::TimeDelta::FromSeconds(i),
+ 1u));
+ }
+
+ // Trigger an eviction.
+ base::ElapsedTimer timer;
+ index.SetMaxSize(kEntries);
+ index.UpdateEntrySize(0, 1u);
+ evict_elapsed_ms += timer.Elapsed().InMillisecondsF();
+ }
+
+ LOG(ERROR) << "Average time to evict:" << (evict_elapsed_ms / iterations)
+ << "ms";
+}
+
} // namespace
« no previous file with comments | « no previous file | net/disk_cache/simple/simple_index.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698