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

Side by Side Diff: chrome/browser/visitedlink_perftest.cc

Issue 342068: Third patch in getting rid of caching MessageLoop pointers and always using C... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 1 month 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 | « chrome/browser/visitedlink_master.cc ('k') | chrome/browser/visitedlink_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) 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 <algorithm> 5 #include <algorithm>
6 #include <string> 6 #include <string>
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 83
84 } // namespace 84 } // namespace
85 85
86 // This test tests adding many things to a database, and how long it takes 86 // This test tests adding many things to a database, and how long it takes
87 // to query the database with different numbers of things in it. The time 87 // to query the database with different numbers of things in it. The time
88 // is the total time to do all the operations, and as such, it is only 88 // is the total time to do all the operations, and as such, it is only
89 // useful for a regression test. If there is a regression, it might be 89 // useful for a regression test. If there is a regression, it might be
90 // useful to make another set of tests to test these things in isolation. 90 // useful to make another set of tests to test these things in isolation.
91 TEST_F(VisitedLink, TestAddAndQuery) { 91 TEST_F(VisitedLink, TestAddAndQuery) {
92 // init 92 // init
93 VisitedLinkMaster master(NULL, DummyVisitedLinkEventListener::GetInstance(), 93 VisitedLinkMaster master(DummyVisitedLinkEventListener::GetInstance(),
94 NULL, true, FilePath(db_name_), 0); 94 NULL, true, FilePath(db_name_), 0);
95 ASSERT_TRUE(master.Init()); 95 ASSERT_TRUE(master.Init());
96 96
97 PerfTimeLogger timer("Visited_link_add_and_query"); 97 PerfTimeLogger timer("Visited_link_add_and_query");
98 98
99 // first check without anything in the table 99 // first check without anything in the table
100 CheckVisited(master, added_prefix, 0, add_count); 100 CheckVisited(master, added_prefix, 0, add_count);
101 101
102 // now fill half the table 102 // now fill half the table
103 const int half_size = add_count / 2; 103 const int half_size = add_count / 2;
(...skipping 10 matching lines...) Expand all
114 CheckVisited(master, added_prefix, 0, add_count); 114 CheckVisited(master, added_prefix, 0, add_count);
115 CheckVisited(master, unadded_prefix, 0, add_count); 115 CheckVisited(master, unadded_prefix, 0, add_count);
116 } 116 }
117 117
118 // Tests how long it takes to write and read a large database to and from disk. 118 // Tests how long it takes to write and read a large database to and from disk.
119 TEST_F(VisitedLink, TestLoad) { 119 TEST_F(VisitedLink, TestLoad) {
120 // create a big DB 120 // create a big DB
121 { 121 {
122 PerfTimeLogger table_initialization_timer("Table_initialization"); 122 PerfTimeLogger table_initialization_timer("Table_initialization");
123 123
124 VisitedLinkMaster master(NULL, DummyVisitedLinkEventListener::GetInstance(), 124 VisitedLinkMaster master(DummyVisitedLinkEventListener::GetInstance(),
125 NULL, true, FilePath(db_name_), 0); 125 NULL, true, FilePath(db_name_), 0);
126 126
127 // time init with empty table 127 // time init with empty table
128 PerfTimeLogger initTimer("Empty_visited_link_init"); 128 PerfTimeLogger initTimer("Empty_visited_link_init");
129 bool success = master.Init(); 129 bool success = master.Init();
130 initTimer.Done(); 130 initTimer.Done();
131 ASSERT_TRUE(success); 131 ASSERT_TRUE(success);
132 132
133 // add a bunch of stuff 133 // add a bunch of stuff
134 // TODO(maruel): This is very inefficient because the file gets rewritten 134 // TODO(maruel): This is very inefficient because the file gets rewritten
(...skipping 18 matching lines...) Expand all
153 std::vector<double> hot_load_times; 153 std::vector<double> hot_load_times;
154 for (int i = 0; i < load_count; i++) { 154 for (int i = 0; i < load_count; i++) {
155 // make sure the file has to be re-loaded 155 // make sure the file has to be re-loaded
156 file_util::EvictFileFromSystemCache( 156 file_util::EvictFileFromSystemCache(
157 FilePath::FromWStringHack(std::wstring(db_name_))); 157 FilePath::FromWStringHack(std::wstring(db_name_)));
158 158
159 // cold load (no OS cache, hopefully) 159 // cold load (no OS cache, hopefully)
160 { 160 {
161 PerfTimer cold_timer; 161 PerfTimer cold_timer;
162 162
163 VisitedLinkMaster master(NULL, 163 VisitedLinkMaster master(DummyVisitedLinkEventListener::GetInstance(),
164 DummyVisitedLinkEventListener::GetInstance(),
165 NULL, 164 NULL,
166 true, 165 true,
167 FilePath(db_name_), 166 FilePath(db_name_),
168 0); 167 0);
169 bool success = master.Init(); 168 bool success = master.Init();
170 TimeDelta elapsed = cold_timer.Elapsed(); 169 TimeDelta elapsed = cold_timer.Elapsed();
171 ASSERT_TRUE(success); 170 ASSERT_TRUE(success);
172 171
173 cold_load_times.push_back(elapsed.InMillisecondsF()); 172 cold_load_times.push_back(elapsed.InMillisecondsF());
174 } 173 }
175 174
176 // hot load (with OS caching the file in memory) 175 // hot load (with OS caching the file in memory)
177 { 176 {
178 PerfTimer hot_timer; 177 PerfTimer hot_timer;
179 178
180 VisitedLinkMaster master(NULL, 179 VisitedLinkMaster master(DummyVisitedLinkEventListener::GetInstance(),
181 DummyVisitedLinkEventListener::GetInstance(),
182 NULL, 180 NULL,
183 true, 181 true,
184 FilePath(db_name_), 182 FilePath(db_name_),
185 0); 183 0);
186 bool success = master.Init(); 184 bool success = master.Init();
187 TimeDelta elapsed = hot_timer.Elapsed(); 185 TimeDelta elapsed = hot_timer.Elapsed();
188 ASSERT_TRUE(success); 186 ASSERT_TRUE(success);
189 187
190 hot_load_times.push_back(elapsed.InMillisecondsF()); 188 hot_load_times.push_back(elapsed.InMillisecondsF());
191 } 189 }
192 } 190 }
193 191
194 // We discard the max and return the average time. 192 // We discard the max and return the average time.
195 cold_load_times.erase(std::max_element(cold_load_times.begin(), 193 cold_load_times.erase(std::max_element(cold_load_times.begin(),
196 cold_load_times.end())); 194 cold_load_times.end()));
197 hot_load_times.erase(std::max_element(hot_load_times.begin(), 195 hot_load_times.erase(std::max_element(hot_load_times.begin(),
198 hot_load_times.end())); 196 hot_load_times.end()));
199 197
200 double cold_sum = 0, hot_sum = 0; 198 double cold_sum = 0, hot_sum = 0;
201 for (int i = 0; i < static_cast<int>(cold_load_times.size()); i++) { 199 for (int i = 0; i < static_cast<int>(cold_load_times.size()); i++) {
202 cold_sum += cold_load_times[i]; 200 cold_sum += cold_load_times[i];
203 hot_sum += hot_load_times[i]; 201 hot_sum += hot_load_times[i];
204 } 202 }
205 LogPerfResult("Visited_link_cold_load_time", 203 LogPerfResult("Visited_link_cold_load_time",
206 cold_sum / cold_load_times.size(), "ms"); 204 cold_sum / cold_load_times.size(), "ms");
207 LogPerfResult("Visited_link_hot_load_time", 205 LogPerfResult("Visited_link_hot_load_time",
208 hot_sum / hot_load_times.size(), "ms"); 206 hot_sum / hot_load_times.size(), "ms");
209 } 207 }
OLDNEW
« no previous file with comments | « chrome/browser/visitedlink_master.cc ('k') | chrome/browser/visitedlink_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698