OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/file_path.h" | 8 #include "base/file_path.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/perftimer.h" | 10 #include "base/perftimer.h" |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 disk_cache::Hash(key); | 152 disk_cache::Hash(key); |
153 } | 153 } |
154 timer.Done(); | 154 timer.Done(); |
155 } | 155 } |
156 | 156 |
157 TEST_F(DiskCacheTest, CacheBackendPerformance) { | 157 TEST_F(DiskCacheTest, CacheBackendPerformance) { |
158 MessageLoopForIO message_loop; | 158 MessageLoopForIO message_loop; |
159 | 159 |
160 ScopedTestCache test_cache; | 160 ScopedTestCache test_cache; |
161 disk_cache::Backend* cache = | 161 disk_cache::Backend* cache = |
162 disk_cache::CreateCacheBackend(test_cache.path_wstring(), false, 0); | 162 disk_cache::CreateCacheBackend(test_cache.path_wstring(), false, 0, |
| 163 net::DISK_CACHE); |
163 ASSERT_TRUE(NULL != cache); | 164 ASSERT_TRUE(NULL != cache); |
164 | 165 |
165 int seed = static_cast<int>(Time::Now().ToInternalValue()); | 166 int seed = static_cast<int>(Time::Now().ToInternalValue()); |
166 srand(seed); | 167 srand(seed); |
167 | 168 |
168 TestEntries entries; | 169 TestEntries entries; |
169 int num_entries = 1000; | 170 int num_entries = 1000; |
170 | 171 |
171 int ret = TimeWrite(num_entries, cache, &entries); | 172 int ret = TimeWrite(num_entries, cache, &entries); |
172 EXPECT_EQ(ret, g_cache_tests_received); | 173 EXPECT_EQ(ret, g_cache_tests_received); |
173 | 174 |
174 MessageLoop::current()->RunAllPending(); | 175 MessageLoop::current()->RunAllPending(); |
175 delete cache; | 176 delete cache; |
176 | 177 |
177 ASSERT_TRUE(file_util::EvictFileFromSystemCache( | 178 ASSERT_TRUE(file_util::EvictFileFromSystemCache( |
178 test_cache.path().AppendASCII("index"))); | 179 test_cache.path().AppendASCII("index"))); |
179 ASSERT_TRUE(file_util::EvictFileFromSystemCache( | 180 ASSERT_TRUE(file_util::EvictFileFromSystemCache( |
180 test_cache.path().AppendASCII("data_0"))); | 181 test_cache.path().AppendASCII("data_0"))); |
181 ASSERT_TRUE(file_util::EvictFileFromSystemCache( | 182 ASSERT_TRUE(file_util::EvictFileFromSystemCache( |
182 test_cache.path().AppendASCII("data_1"))); | 183 test_cache.path().AppendASCII("data_1"))); |
183 ASSERT_TRUE(file_util::EvictFileFromSystemCache( | 184 ASSERT_TRUE(file_util::EvictFileFromSystemCache( |
184 test_cache.path().AppendASCII("data_2"))); | 185 test_cache.path().AppendASCII("data_2"))); |
185 ASSERT_TRUE(file_util::EvictFileFromSystemCache( | 186 ASSERT_TRUE(file_util::EvictFileFromSystemCache( |
186 test_cache.path().AppendASCII("data_3"))); | 187 test_cache.path().AppendASCII("data_3"))); |
187 | 188 |
188 cache = disk_cache::CreateCacheBackend(test_cache.path_wstring(), false, 0); | 189 cache = disk_cache::CreateCacheBackend(test_cache.path_wstring(), false, 0, |
| 190 net::DISK_CACHE); |
189 ASSERT_TRUE(NULL != cache); | 191 ASSERT_TRUE(NULL != cache); |
190 | 192 |
191 ret = TimeRead(num_entries, cache, entries, true); | 193 ret = TimeRead(num_entries, cache, entries, true); |
192 EXPECT_EQ(ret, g_cache_tests_received); | 194 EXPECT_EQ(ret, g_cache_tests_received); |
193 | 195 |
194 ret = TimeRead(num_entries, cache, entries, false); | 196 ret = TimeRead(num_entries, cache, entries, false); |
195 EXPECT_EQ(ret, g_cache_tests_received); | 197 EXPECT_EQ(ret, g_cache_tests_received); |
196 | 198 |
197 MessageLoop::current()->RunAllPending(); | 199 MessageLoop::current()->RunAllPending(); |
198 delete cache; | 200 delete cache; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 entry = 0; | 239 entry = 0; |
238 | 240 |
239 files.DeleteBlock(address[entry], false); | 241 files.DeleteBlock(address[entry], false); |
240 EXPECT_TRUE(files.CreateBlock(disk_cache::RANKINGS, BlockSize(), | 242 EXPECT_TRUE(files.CreateBlock(disk_cache::RANKINGS, BlockSize(), |
241 &address[entry])); | 243 &address[entry])); |
242 } | 244 } |
243 | 245 |
244 timer2.Done(); | 246 timer2.Done(); |
245 MessageLoop::current()->RunAllPending(); | 247 MessageLoop::current()->RunAllPending(); |
246 } | 248 } |
OLD | NEW |