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

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

Issue 10920026: Move hash.h/cc from net/disk_cache to base. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: willchan, rvargas feedback Created 8 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « net/disk_cache/backend_impl.cc ('k') | net/disk_cache/entry_impl.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 <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/perftimer.h" 11 #include "base/perftimer.h"
11 #include "base/string_util.h" 12 #include "base/string_util.h"
12 #include "base/threading/thread.h" 13 #include "base/threading/thread.h"
13 #include "base/test/test_file_util.h" 14 #include "base/test/test_file_util.h"
14 #include "base/timer.h" 15 #include "base/timer.h"
15 #include "net/base/io_buffer.h" 16 #include "net/base/io_buffer.h"
16 #include "net/base/net_errors.h" 17 #include "net/base/net_errors.h"
17 #include "net/base/test_completion_callback.h" 18 #include "net/base/test_completion_callback.h"
18 #include "net/disk_cache/block_files.h" 19 #include "net/disk_cache/block_files.h"
19 #include "net/disk_cache/backend_impl.h" 20 #include "net/disk_cache/backend_impl.h"
20 #include "net/disk_cache/disk_cache.h" 21 #include "net/disk_cache/disk_cache.h"
21 #include "net/disk_cache/disk_cache_test_base.h" 22 #include "net/disk_cache/disk_cache_test_base.h"
22 #include "net/disk_cache/disk_cache_test_util.h" 23 #include "net/disk_cache/disk_cache_test_util.h"
23 #include "net/disk_cache/hash.h"
24 #include "testing/gtest/include/gtest/gtest.h" 24 #include "testing/gtest/include/gtest/gtest.h"
25 #include "testing/platform_test.h" 25 #include "testing/platform_test.h"
26 26
27 using base::Time; 27 using base::Time;
28 28
29 namespace { 29 namespace {
30 30
31 struct TestEntry { 31 struct TestEntry {
32 std::string key; 32 std::string key;
33 int data_len; 33 int data_len;
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 145
146 } // namespace 146 } // namespace
147 147
148 TEST_F(DiskCacheTest, Hash) { 148 TEST_F(DiskCacheTest, Hash) {
149 int seed = static_cast<int>(Time::Now().ToInternalValue()); 149 int seed = static_cast<int>(Time::Now().ToInternalValue());
150 srand(seed); 150 srand(seed);
151 151
152 PerfTimeLogger timer("Hash disk cache keys"); 152 PerfTimeLogger timer("Hash disk cache keys");
153 for (int i = 0; i < 300000; i++) { 153 for (int i = 0; i < 300000; i++) {
154 std::string key = GenerateKey(true); 154 std::string key = GenerateKey(true);
155 disk_cache::Hash(key); 155 base::Hash(key);
156 } 156 }
157 timer.Done(); 157 timer.Done();
158 } 158 }
159 159
160 TEST_F(DiskCacheTest, CacheBackendPerformance) { 160 TEST_F(DiskCacheTest, CacheBackendPerformance) {
161 base::Thread cache_thread("CacheThread"); 161 base::Thread cache_thread("CacheThread");
162 ASSERT_TRUE(cache_thread.StartWithOptions( 162 ASSERT_TRUE(cache_thread.StartWithOptions(
163 base::Thread::Options(MessageLoop::TYPE_IO, 0))); 163 base::Thread::Options(MessageLoop::TYPE_IO, 0)));
164 164
165 ASSERT_TRUE(CleanupCacheDir()); 165 ASSERT_TRUE(CleanupCacheDir());
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 MessageLoop::current()->RunAllPending(); 248 MessageLoop::current()->RunAllPending();
249 delete[] address; 249 delete[] address;
250 } 250 }
OLDNEW
« no previous file with comments | « net/disk_cache/backend_impl.cc ('k') | net/disk_cache/entry_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698