Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
| 15 #include "base/test/perf_time_logger.h" | 15 #include "base/test/perf_time_logger.h" |
| 16 #include "base/test/test_file_util.h" | 16 #include "base/test/test_file_util.h" |
| 17 #include "base/threading/thread.h" | 17 #include "base/threading/thread.h" |
| 18 #include "net/base/cache_type.h" | 18 #include "net/base/cache_type.h" |
| 19 #include "net/base/io_buffer.h" | 19 #include "net/base/io_buffer.h" |
| 20 #include "net/base/net_errors.h" | 20 #include "net/base/net_errors.h" |
| 21 #include "net/base/test_completion_callback.h" | 21 #include "net/base/test_completion_callback.h" |
| 22 #include "net/disk_cache/blockfile/backend_impl.h" | 22 #include "net/disk_cache/blockfile/backend_impl.h" |
| 23 #include "net/disk_cache/blockfile/block_files.h" | 23 #include "net/disk_cache/blockfile/block_files.h" |
| 24 #include "net/disk_cache/disk_cache.h" | 24 #include "net/disk_cache/disk_cache.h" |
| 25 #include "net/disk_cache/disk_cache_test_base.h" | 25 #include "net/disk_cache/disk_cache_test_base.h" |
| 26 #include "net/disk_cache/disk_cache_test_util.h" | 26 #include "net/disk_cache/disk_cache_test_util.h" |
| 27 #include "net/disk_cache/simple/simple_backend_impl.h" | |
| 27 #include "testing/gtest/include/gtest/gtest.h" | 28 #include "testing/gtest/include/gtest/gtest.h" |
| 28 #include "testing/platform_test.h" | 29 #include "testing/platform_test.h" |
| 29 | 30 |
| 30 using base::Time; | 31 using base::Time; |
| 31 | 32 |
| 32 namespace { | 33 namespace { |
| 33 | 34 |
| 34 size_t MaybeGetMaxFds() { | 35 size_t MaybeGetMaxFds() { |
| 35 #if defined(OS_POSIX) | 36 #if defined(OS_POSIX) |
| 36 return base::GetMaxFds(); | 37 return base::GetMaxFds(); |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 228 #endif | 229 #endif |
| 229 | 230 |
| 230 DisableFirstCleanup(); | 231 DisableFirstCleanup(); |
| 231 InitCache(); | 232 InitCache(); |
| 232 } | 233 } |
| 233 | 234 |
| 234 void DiskCachePerfTest::CacheBackendPerformance() { | 235 void DiskCachePerfTest::CacheBackendPerformance() { |
| 235 InitCache(); | 236 InitCache(); |
| 236 EXPECT_TRUE(TimeWrite()); | 237 EXPECT_TRUE(TimeWrite()); |
| 237 | 238 |
| 239 base::MessageLoop::current()->RunUntilIdle(); | |
|
Randy Smith (Not in Mondays)
2016/05/26 18:26:25
Why is this needed? I'd think that FlushWorkerPoo
gavinp
2016/05/26 19:03:29
You're right; I was just anxious because this has
| |
| 240 disk_cache::SimpleBackendImpl::FlushWorkerPoolForTesting(); | |
| 241 base::MessageLoop::current()->RunUntilIdle(); | |
| 242 | |
| 238 ResetAndEvictSystemDiskCache(); | 243 ResetAndEvictSystemDiskCache(); |
| 239 EXPECT_TRUE(TimeRead(WhatToRead::HEADERS_ONLY, | 244 EXPECT_TRUE(TimeRead(WhatToRead::HEADERS_ONLY, |
| 240 "Read disk cache headers only (cold)")); | 245 "Read disk cache headers only (cold)")); |
| 241 EXPECT_TRUE(TimeRead(WhatToRead::HEADERS_ONLY, | 246 EXPECT_TRUE(TimeRead(WhatToRead::HEADERS_ONLY, |
| 242 "Read disk cache headers only (warm)")); | 247 "Read disk cache headers only (warm)")); |
| 248 | |
| 249 base::MessageLoop::current()->RunUntilIdle(); | |
|
Randy Smith (Not in Mondays)
2016/05/26 18:26:25
I'm a bit more worried about this one, as its plac
gavinp
2016/05/26 19:03:29
The Close() operations after each of the reads nee
| |
| 250 disk_cache::SimpleBackendImpl::FlushWorkerPoolForTesting(); | |
| 243 base::MessageLoop::current()->RunUntilIdle(); | 251 base::MessageLoop::current()->RunUntilIdle(); |
| 244 | 252 |
| 245 ResetAndEvictSystemDiskCache(); | 253 ResetAndEvictSystemDiskCache(); |
| 246 EXPECT_TRUE( | 254 EXPECT_TRUE( |
| 247 TimeRead(WhatToRead::HEADERS_AND_BODY, "Read disk cache entries (cold)")); | 255 TimeRead(WhatToRead::HEADERS_AND_BODY, "Read disk cache entries (cold)")); |
| 248 EXPECT_TRUE( | 256 EXPECT_TRUE( |
| 249 TimeRead(WhatToRead::HEADERS_AND_BODY, "Read disk cache entries (warm)")); | 257 TimeRead(WhatToRead::HEADERS_AND_BODY, "Read disk cache entries (warm)")); |
|
Randy Smith (Not in Mondays)
2016/05/26 18:26:25
What's the larger context in which this test is ru
gavinp
2016/05/26 19:03:29
Ah, we don't tear down the worker pool after tests
| |
| 250 base::MessageLoop::current()->RunUntilIdle(); | |
| 251 } | 258 } |
| 252 | 259 |
| 253 TEST_F(DiskCachePerfTest, CacheBackendPerformance) { | 260 TEST_F(DiskCachePerfTest, CacheBackendPerformance) { |
| 254 CacheBackendPerformance(); | 261 CacheBackendPerformance(); |
| 255 } | 262 } |
| 256 | 263 |
| 257 TEST_F(DiskCachePerfTest, SimpleCacheBackendPerformance) { | 264 TEST_F(DiskCachePerfTest, SimpleCacheBackendPerformance) { |
| 258 SetSimpleCacheMode(); | 265 SetSimpleCacheMode(); |
| 259 CacheBackendPerformance(); | 266 CacheBackendPerformance(); |
| 260 } | 267 } |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 300 files.DeleteBlock(address[entry], false); | 307 files.DeleteBlock(address[entry], false); |
| 301 EXPECT_TRUE( | 308 EXPECT_TRUE( |
| 302 files.CreateBlock(disk_cache::RANKINGS, BlockSize(), &address[entry])); | 309 files.CreateBlock(disk_cache::RANKINGS, BlockSize(), &address[entry])); |
| 303 } | 310 } |
| 304 | 311 |
| 305 timer2.Done(); | 312 timer2.Done(); |
| 306 base::MessageLoop::current()->RunUntilIdle(); | 313 base::MessageLoop::current()->RunUntilIdle(); |
| 307 } | 314 } |
| 308 | 315 |
| 309 } // namespace | 316 } // namespace |
| OLD | NEW |