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

Side by Side Diff: net/disk_cache/disk_cache_perftest.cc

Issue 2053133002: Remove MessageLoop::current()->RunUntilIdle() in net. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 unified diff | Download patch
« no previous file with comments | « net/disk_cache/backend_unittest.cc ('k') | net/disk_cache/entry_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <limits> 5 #include <limits>
6 #include <string> 6 #include <string>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/bind_helpers.h" 9 #include "base/bind_helpers.h"
10 #include "base/files/file_enumerator.h" 10 #include "base/files/file_enumerator.h"
11 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
12 #include "base/hash.h" 12 #include "base/hash.h"
13 #include "base/process/process_metrics.h" 13 #include "base/process/process_metrics.h"
14 #include "base/run_loop.h"
14 #include "base/strings/string_util.h" 15 #include "base/strings/string_util.h"
15 #include "base/test/perf_time_logger.h" 16 #include "base/test/perf_time_logger.h"
16 #include "base/test/test_file_util.h" 17 #include "base/test/test_file_util.h"
17 #include "base/threading/thread.h" 18 #include "base/threading/thread.h"
18 #include "net/base/cache_type.h" 19 #include "net/base/cache_type.h"
19 #include "net/base/io_buffer.h" 20 #include "net/base/io_buffer.h"
20 #include "net/base/net_errors.h" 21 #include "net/base/net_errors.h"
21 #include "net/base/test_completion_callback.h" 22 #include "net/base/test_completion_callback.h"
22 #include "net/disk_cache/blockfile/backend_impl.h" 23 #include "net/disk_cache/blockfile/backend_impl.h"
23 #include "net/disk_cache/blockfile/block_files.h" 24 #include "net/disk_cache/blockfile/block_files.h"
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 201
201 base::PerfTimeLogger timer("Hash disk cache keys"); 202 base::PerfTimeLogger timer("Hash disk cache keys");
202 for (int i = 0; i < 300000; i++) { 203 for (int i = 0; i < 300000; i++) {
203 std::string key = GenerateKey(true); 204 std::string key = GenerateKey(true);
204 base::Hash(key); 205 base::Hash(key);
205 } 206 }
206 timer.Done(); 207 timer.Done();
207 } 208 }
208 209
209 void DiskCachePerfTest::ResetAndEvictSystemDiskCache() { 210 void DiskCachePerfTest::ResetAndEvictSystemDiskCache() {
210 base::MessageLoop::current()->RunUntilIdle(); 211 base::RunLoop().RunUntilIdle();
211 cache_.reset(); 212 cache_.reset();
212 213
213 // Flush all files in the cache out of system memory. 214 // Flush all files in the cache out of system memory.
214 const base::FilePath::StringType file_pattern = FILE_PATH_LITERAL("*"); 215 const base::FilePath::StringType file_pattern = FILE_PATH_LITERAL("*");
215 base::FileEnumerator enumerator(cache_path_, true /* recursive */, 216 base::FileEnumerator enumerator(cache_path_, true /* recursive */,
216 base::FileEnumerator::FILES, file_pattern); 217 base::FileEnumerator::FILES, file_pattern);
217 for (base::FilePath file_path = enumerator.Next(); !file_path.empty(); 218 for (base::FilePath file_path = enumerator.Next(); !file_path.empty();
218 file_path = enumerator.Next()) { 219 file_path = enumerator.Next()) {
219 ASSERT_TRUE(base::EvictFileFromSystemCache(file_path)); 220 ASSERT_TRUE(base::EvictFileFromSystemCache(file_path));
220 } 221 }
221 #if defined(OS_LINUX) 222 #if defined(OS_LINUX)
222 // And, cache directories, on platforms where the eviction utility supports 223 // And, cache directories, on platforms where the eviction utility supports
223 // this (currently Linux only). 224 // this (currently Linux only).
224 if (simple_cache_mode_) { 225 if (simple_cache_mode_) {
225 ASSERT_TRUE( 226 ASSERT_TRUE(
226 base::EvictFileFromSystemCache(cache_path_.AppendASCII("index-dir"))); 227 base::EvictFileFromSystemCache(cache_path_.AppendASCII("index-dir")));
227 } 228 }
228 ASSERT_TRUE(base::EvictFileFromSystemCache(cache_path_)); 229 ASSERT_TRUE(base::EvictFileFromSystemCache(cache_path_));
229 #endif 230 #endif
230 231
231 DisableFirstCleanup(); 232 DisableFirstCleanup();
232 InitCache(); 233 InitCache();
233 } 234 }
234 235
235 void DiskCachePerfTest::CacheBackendPerformance() { 236 void DiskCachePerfTest::CacheBackendPerformance() {
236 InitCache(); 237 InitCache();
237 EXPECT_TRUE(TimeWrite()); 238 EXPECT_TRUE(TimeWrite());
238 239
239 disk_cache::SimpleBackendImpl::FlushWorkerPoolForTesting(); 240 disk_cache::SimpleBackendImpl::FlushWorkerPoolForTesting();
240 base::MessageLoop::current()->RunUntilIdle(); 241 base::RunLoop().RunUntilIdle();
241 242
242 ResetAndEvictSystemDiskCache(); 243 ResetAndEvictSystemDiskCache();
243 EXPECT_TRUE(TimeRead(WhatToRead::HEADERS_ONLY, 244 EXPECT_TRUE(TimeRead(WhatToRead::HEADERS_ONLY,
244 "Read disk cache headers only (cold)")); 245 "Read disk cache headers only (cold)"));
245 EXPECT_TRUE(TimeRead(WhatToRead::HEADERS_ONLY, 246 EXPECT_TRUE(TimeRead(WhatToRead::HEADERS_ONLY,
246 "Read disk cache headers only (warm)")); 247 "Read disk cache headers only (warm)"));
247 248
248 disk_cache::SimpleBackendImpl::FlushWorkerPoolForTesting(); 249 disk_cache::SimpleBackendImpl::FlushWorkerPoolForTesting();
249 base::MessageLoop::current()->RunUntilIdle(); 250 base::RunLoop().RunUntilIdle();
250 251
251 ResetAndEvictSystemDiskCache(); 252 ResetAndEvictSystemDiskCache();
252 EXPECT_TRUE( 253 EXPECT_TRUE(
253 TimeRead(WhatToRead::HEADERS_AND_BODY, "Read disk cache entries (cold)")); 254 TimeRead(WhatToRead::HEADERS_AND_BODY, "Read disk cache entries (cold)"));
254 EXPECT_TRUE( 255 EXPECT_TRUE(
255 TimeRead(WhatToRead::HEADERS_AND_BODY, "Read disk cache entries (warm)")); 256 TimeRead(WhatToRead::HEADERS_AND_BODY, "Read disk cache entries (warm)"));
256 257
257 disk_cache::SimpleBackendImpl::FlushWorkerPoolForTesting(); 258 disk_cache::SimpleBackendImpl::FlushWorkerPoolForTesting();
258 base::MessageLoop::current()->RunUntilIdle(); 259 base::RunLoop().RunUntilIdle();
259 } 260 }
260 261
261 TEST_F(DiskCachePerfTest, CacheBackendPerformance) { 262 TEST_F(DiskCachePerfTest, CacheBackendPerformance) {
262 CacheBackendPerformance(); 263 CacheBackendPerformance();
263 } 264 }
264 265
265 TEST_F(DiskCachePerfTest, SimpleCacheBackendPerformance) { 266 TEST_F(DiskCachePerfTest, SimpleCacheBackendPerformance) {
266 SetSimpleCacheMode(); 267 SetSimpleCacheMode();
267 CacheBackendPerformance(); 268 CacheBackendPerformance();
268 } 269 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 int entry = rand() * (kNumBlocks / RAND_MAX + 1); 305 int entry = rand() * (kNumBlocks / RAND_MAX + 1);
305 if (entry >= kNumBlocks) 306 if (entry >= kNumBlocks)
306 entry = 0; 307 entry = 0;
307 308
308 files.DeleteBlock(address[entry], false); 309 files.DeleteBlock(address[entry], false);
309 EXPECT_TRUE( 310 EXPECT_TRUE(
310 files.CreateBlock(disk_cache::RANKINGS, BlockSize(), &address[entry])); 311 files.CreateBlock(disk_cache::RANKINGS, BlockSize(), &address[entry]));
311 } 312 }
312 313
313 timer2.Done(); 314 timer2.Done();
314 base::MessageLoop::current()->RunUntilIdle(); 315 base::RunLoop().RunUntilIdle();
315 } 316 }
316 317
317 } // namespace 318 } // namespace
OLDNEW
« no previous file with comments | « net/disk_cache/backend_unittest.cc ('k') | net/disk_cache/entry_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698