| 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 <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_util.h" | 10 #include "base/file_util.h" |
| 10 #include "base/perftimer.h" | 11 #include "base/perftimer.h" |
| 11 #include "base/shared_memory.h" | 12 #include "base/shared_memory.h" |
| 12 #include "base/string_util.h" | 13 #include "base/string_util.h" |
| 13 #include "base/test_file_util.h" | 14 #include "base/test_file_util.h" |
| 14 #include "chrome/browser/visitedlink_master.h" | 15 #include "chrome/browser/visitedlink_master.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 16 | 17 |
| 17 using base::TimeDelta; | 18 using base::TimeDelta; |
| 18 | 19 |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 } | 137 } |
| 137 | 138 |
| 138 // test loading the DB back, we do this several times since the flushing is | 139 // test loading the DB back, we do this several times since the flushing is |
| 139 // not very reliable. | 140 // not very reliable. |
| 140 const int load_count = 5; | 141 const int load_count = 5; |
| 141 std::vector<double> cold_load_times; | 142 std::vector<double> cold_load_times; |
| 142 std::vector<double> hot_load_times; | 143 std::vector<double> hot_load_times; |
| 143 for (int i = 0; i < load_count; i++) | 144 for (int i = 0; i < load_count; i++) |
| 144 { | 145 { |
| 145 // make sure the file has to be re-loaded | 146 // make sure the file has to be re-loaded |
| 146 file_util::EvictFileFromSystemCache(db_name_.c_str()); | 147 file_util::EvictFileFromSystemCache( |
| 148 FilePath::FromWStringHack(std::wstring(db_name_))); |
| 147 | 149 |
| 148 // cold load (no OS cache, hopefully) | 150 // cold load (no OS cache, hopefully) |
| 149 { | 151 { |
| 150 PerfTimer cold_timer; | 152 PerfTimer cold_timer; |
| 151 | 153 |
| 152 VisitedLinkMaster master(NULL, DummyBroadcastNewTableEvent, NULL, true, | 154 VisitedLinkMaster master(NULL, DummyBroadcastNewTableEvent, NULL, true, |
| 153 db_name_, 0); | 155 db_name_, 0); |
| 154 bool success = master.Init(); | 156 bool success = master.Init(); |
| 155 TimeDelta elapsed = cold_timer.Elapsed(); | 157 TimeDelta elapsed = cold_timer.Elapsed(); |
| 156 ASSERT_TRUE(success); | 158 ASSERT_TRUE(success); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 182 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++) { |
| 183 cold_sum += cold_load_times[i]; | 185 cold_sum += cold_load_times[i]; |
| 184 hot_sum += hot_load_times[i]; | 186 hot_sum += hot_load_times[i]; |
| 185 } | 187 } |
| 186 LogPerfResult("Visited_link_cold_load_time", | 188 LogPerfResult("Visited_link_cold_load_time", |
| 187 cold_sum / cold_load_times.size(), "ms"); | 189 cold_sum / cold_load_times.size(), "ms"); |
| 188 LogPerfResult("Visited_link_hot_load_time", | 190 LogPerfResult("Visited_link_hot_load_time", |
| 189 hot_sum / hot_load_times.size(), "ms"); | 191 hot_sum / hot_load_times.size(), "ms"); |
| 190 } | 192 } |
| 191 | 193 |
| OLD | NEW |