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

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

Issue 19028: Roll forward 8722,8721 (Closed)
Patch Set: Created 11 years, 11 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
« 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 } // namespace 74 } // namespace
75 75
76 // This test tests adding many things to a database, and how long it takes 76 // This test tests adding many things to a database, and how long it takes
77 // to query the database with different numbers of things in it. The time 77 // to query the database with different numbers of things in it. The time
78 // is the total time to do all the operations, and as such, it is only 78 // is the total time to do all the operations, and as such, it is only
79 // useful for a regression test. If there is a regression, it might be 79 // useful for a regression test. If there is a regression, it might be
80 // useful to make another set of tests to test these things in isolation. 80 // useful to make another set of tests to test these things in isolation.
81 TEST_F(VisitedLink, TestAddAndQuery) { 81 TEST_F(VisitedLink, TestAddAndQuery) {
82 // init 82 // init
83 VisitedLinkMaster master(NULL, DummyBroadcastNewTableEvent, NULL, true, 83 VisitedLinkMaster master(NULL, DummyBroadcastNewTableEvent, NULL, true,
84 db_name_, 0); 84 FilePath(db_name_), 0);
85 ASSERT_TRUE(master.Init()); 85 ASSERT_TRUE(master.Init());
86 86
87 PerfTimeLogger timer("Visited_link_add_and_query"); 87 PerfTimeLogger timer("Visited_link_add_and_query");
88 88
89 // first check without anything in the table 89 // first check without anything in the table
90 CheckVisited(master, added_prefix, 0, add_count); 90 CheckVisited(master, added_prefix, 0, add_count);
91 91
92 // now fill half the table 92 // now fill half the table
93 const int half_size = add_count / 2; 93 const int half_size = add_count / 2;
94 FillTable(master, added_prefix, 0, half_size); 94 FillTable(master, added_prefix, 0, half_size);
(...skipping 10 matching lines...) Expand all
105 CheckVisited(master, unadded_prefix, 0, add_count); 105 CheckVisited(master, unadded_prefix, 0, add_count);
106 } 106 }
107 107
108 // Tests how long it takes to write and read a large database to and from disk. 108 // Tests how long it takes to write and read a large database to and from disk.
109 TEST_F(VisitedLink, TestLoad) { 109 TEST_F(VisitedLink, TestLoad) {
110 // create a big DB 110 // create a big DB
111 { 111 {
112 PerfTimeLogger table_initialization_timer("Table_initialization"); 112 PerfTimeLogger table_initialization_timer("Table_initialization");
113 113
114 VisitedLinkMaster master(NULL, DummyBroadcastNewTableEvent, NULL, true, 114 VisitedLinkMaster master(NULL, DummyBroadcastNewTableEvent, NULL, true,
115 db_name_, 0); 115 FilePath(db_name_), 0);
116 116
117 // time init with empty table 117 // time init with empty table
118 PerfTimeLogger initTimer("Empty_visited_link_init"); 118 PerfTimeLogger initTimer("Empty_visited_link_init");
119 bool success = master.Init(); 119 bool success = master.Init();
120 initTimer.Done(); 120 initTimer.Done();
121 ASSERT_TRUE(success); 121 ASSERT_TRUE(success);
122 122
123 // add a bunch of stuff 123 // add a bunch of stuff
124 // TODO(maruel): This is very inefficient because the file gets rewritten 124 // TODO(maruel): This is very inefficient because the file gets rewritten
125 // many time and this is the actual bottleneck of this test. The file should 125 // many time and this is the actual bottleneck of this test. The file should
(...skipping 19 matching lines...) Expand all
145 { 145 {
146 // make sure the file has to be re-loaded 146 // make sure the file has to be re-loaded
147 file_util::EvictFileFromSystemCache( 147 file_util::EvictFileFromSystemCache(
148 FilePath::FromWStringHack(std::wstring(db_name_))); 148 FilePath::FromWStringHack(std::wstring(db_name_)));
149 149
150 // cold load (no OS cache, hopefully) 150 // cold load (no OS cache, hopefully)
151 { 151 {
152 PerfTimer cold_timer; 152 PerfTimer cold_timer;
153 153
154 VisitedLinkMaster master(NULL, DummyBroadcastNewTableEvent, NULL, true, 154 VisitedLinkMaster master(NULL, DummyBroadcastNewTableEvent, NULL, true,
155 db_name_, 0); 155 FilePath(db_name_), 0);
156 bool success = master.Init(); 156 bool success = master.Init();
157 TimeDelta elapsed = cold_timer.Elapsed(); 157 TimeDelta elapsed = cold_timer.Elapsed();
158 ASSERT_TRUE(success); 158 ASSERT_TRUE(success);
159 159
160 cold_load_times.push_back(elapsed.InMillisecondsF()); 160 cold_load_times.push_back(elapsed.InMillisecondsF());
161 } 161 }
162 162
163 // hot load (with OS caching the file in memory) 163 // hot load (with OS caching the file in memory)
164 { 164 {
165 PerfTimer hot_timer; 165 PerfTimer hot_timer;
166 166
167 VisitedLinkMaster master(NULL, DummyBroadcastNewTableEvent, NULL, true, 167 VisitedLinkMaster master(NULL, DummyBroadcastNewTableEvent, NULL, true,
168 db_name_, 0); 168 FilePath(db_name_), 0);
169 bool success = master.Init(); 169 bool success = master.Init();
170 TimeDelta elapsed = hot_timer.Elapsed(); 170 TimeDelta elapsed = hot_timer.Elapsed();
171 ASSERT_TRUE(success); 171 ASSERT_TRUE(success);
172 172
173 hot_load_times.push_back(elapsed.InMillisecondsF()); 173 hot_load_times.push_back(elapsed.InMillisecondsF());
174 } 174 }
175 } 175 }
176 176
177 // We discard the max and return the average time. 177 // We discard the max and return the average time.
178 cold_load_times.erase(std::max_element(cold_load_times.begin(), 178 cold_load_times.erase(std::max_element(cold_load_times.begin(),
179 cold_load_times.end())); 179 cold_load_times.end()));
180 hot_load_times.erase(std::max_element(hot_load_times.begin(), 180 hot_load_times.erase(std::max_element(hot_load_times.begin(),
181 hot_load_times.end())); 181 hot_load_times.end()));
182 182
183 double cold_sum = 0, hot_sum = 0; 183 double cold_sum = 0, hot_sum = 0;
184 for (int i = 0; i < static_cast<int>(cold_load_times.size()); i++) { 184 for (int i = 0; i < static_cast<int>(cold_load_times.size()); i++) {
185 cold_sum += cold_load_times[i]; 185 cold_sum += cold_load_times[i];
186 hot_sum += hot_load_times[i]; 186 hot_sum += hot_load_times[i];
187 } 187 }
188 LogPerfResult("Visited_link_cold_load_time", 188 LogPerfResult("Visited_link_cold_load_time",
189 cold_sum / cold_load_times.size(), "ms"); 189 cold_sum / cold_load_times.size(), "ms");
190 LogPerfResult("Visited_link_hot_load_time", 190 LogPerfResult("Visited_link_hot_load_time",
191 hot_sum / hot_load_times.size(), "ms"); 191 hot_sum / hot_load_times.size(), "ms");
192 } 192 }
193 193
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