| 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 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/hash.h" | 10 #include "base/hash.h" |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 | 208 |
| 209 // Creating and deleting "entries" on a block-file is something quite frequent | 209 // Creating and deleting "entries" on a block-file is something quite frequent |
| 210 // (after all, almost everything is stored on block files). The operation is | 210 // (after all, almost everything is stored on block files). The operation is |
| 211 // almost free when the file is empty, but can be expensive if the file gets | 211 // almost free when the file is empty, but can be expensive if the file gets |
| 212 // fragmented, or if we have multiple files. This test measures that scenario, | 212 // fragmented, or if we have multiple files. This test measures that scenario, |
| 213 // by using multiple, highly fragmented files. | 213 // by using multiple, highly fragmented files. |
| 214 TEST_F(DiskCacheTest, BlockFilesPerformance) { | 214 TEST_F(DiskCacheTest, BlockFilesPerformance) { |
| 215 ASSERT_TRUE(CleanupCacheDir()); | 215 ASSERT_TRUE(CleanupCacheDir()); |
| 216 | 216 |
| 217 disk_cache::BlockFiles files(cache_path_); | 217 disk_cache::BlockFiles files(cache_path_); |
| 218 ASSERT_TRUE(files.Init(true)); | 218 ASSERT_TRUE(files.Init(true, disk_cache::kFirstAdditionalBlockFile)); |
| 219 | 219 |
| 220 int seed = static_cast<int>(Time::Now().ToInternalValue()); | 220 int seed = static_cast<int>(Time::Now().ToInternalValue()); |
| 221 srand(seed); | 221 srand(seed); |
| 222 | 222 |
| 223 const int kNumEntries = 60000; | 223 const int kNumEntries = 60000; |
| 224 disk_cache::Addr* address = new disk_cache::Addr[kNumEntries]; | 224 disk_cache::Addr* address = new disk_cache::Addr[kNumEntries]; |
| 225 | 225 |
| 226 base::PerfTimeLogger timer1("Fill three block-files"); | 226 base::PerfTimeLogger timer1("Fill three block-files"); |
| 227 | 227 |
| 228 // Fill up the 32-byte block file (use three files). | 228 // Fill up the 32-byte block file (use three files). |
| (...skipping 12 matching lines...) Expand all Loading... |
| 241 | 241 |
| 242 files.DeleteBlock(address[entry], false); | 242 files.DeleteBlock(address[entry], false); |
| 243 EXPECT_TRUE(files.CreateBlock(disk_cache::RANKINGS, BlockSize(), | 243 EXPECT_TRUE(files.CreateBlock(disk_cache::RANKINGS, BlockSize(), |
| 244 &address[entry])); | 244 &address[entry])); |
| 245 } | 245 } |
| 246 | 246 |
| 247 timer2.Done(); | 247 timer2.Done(); |
| 248 base::MessageLoop::current()->RunUntilIdle(); | 248 base::MessageLoop::current()->RunUntilIdle(); |
| 249 delete[] address; | 249 delete[] address; |
| 250 } | 250 } |
| OLD | NEW |