| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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" |
| 11 #include "base/perftimer.h" | 11 #include "base/perftimer.h" |
| 12 #include "base/shared_memory.h" | 12 #include "base/shared_memory.h" |
| 13 #include "base/string_util.h" | 13 #include "base/stringprintf.h" |
| 14 #include "base/test/test_file_util.h" | 14 #include "base/test/test_file_util.h" |
| 15 #include "chrome/browser/visitedlink/visitedlink_master.h" | 15 #include "chrome/browser/visitedlink/visitedlink_master.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 17 | 17 |
| 18 using base::TimeDelta; | 18 using base::TimeDelta; |
| 19 | 19 |
| 20 namespace { | 20 namespace { |
| 21 | 21 |
| 22 // how we generate URLs, note that the two strings should be the same length | 22 // how we generate URLs, note that the two strings should be the same length |
| 23 const int add_count = 10000; | 23 const int add_count = 10000; |
| 24 const int load_test_add_count = 250000; | 24 const int load_test_add_count = 250000; |
| 25 const char added_prefix[] = "http://www.google.com/stuff/something/foo?session=8
5025602345625&id=1345142319023&seq="; | 25 const char added_prefix[] = "http://www.google.com/stuff/something/foo?session=8
5025602345625&id=1345142319023&seq="; |
| 26 const char unadded_prefix[] = "http://www.google.org/stuff/something/foo?session
=39586739476365&id=2347624314402&seq="; | 26 const char unadded_prefix[] = "http://www.google.org/stuff/something/foo?session
=39586739476365&id=2347624314402&seq="; |
| 27 | 27 |
| 28 // Returns a URL with the given prefix and index | 28 // Returns a URL with the given prefix and index |
| 29 GURL TestURL(const char* prefix, int i) { | 29 GURL TestURL(const char* prefix, int i) { |
| 30 return GURL(StringPrintf("%s%d", prefix, i)); | 30 return GURL(base::StringPrintf("%s%d", prefix, i)); |
| 31 } | 31 } |
| 32 | 32 |
| 33 // We have no slaves, so all methods on this listener are a no-ops. | 33 // We have no slaves, so all methods on this listener are a no-ops. |
| 34 class DummyVisitedLinkEventListener : public VisitedLinkMaster::Listener { | 34 class DummyVisitedLinkEventListener : public VisitedLinkMaster::Listener { |
| 35 public: | 35 public: |
| 36 DummyVisitedLinkEventListener() {} | 36 DummyVisitedLinkEventListener() {} |
| 37 virtual void NewTable(base::SharedMemory* table) {} | 37 virtual void NewTable(base::SharedMemory* table) {} |
| 38 virtual void Add(VisitedLinkCommon::Fingerprint) {} | 38 virtual void Add(VisitedLinkCommon::Fingerprint) {} |
| 39 virtual void Reset() {} | 39 virtual void Reset() {} |
| 40 | 40 |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 double cold_sum = 0, hot_sum = 0; | 188 double cold_sum = 0, hot_sum = 0; |
| 189 for (int i = 0; i < static_cast<int>(cold_load_times.size()); i++) { | 189 for (int i = 0; i < static_cast<int>(cold_load_times.size()); i++) { |
| 190 cold_sum += cold_load_times[i]; | 190 cold_sum += cold_load_times[i]; |
| 191 hot_sum += hot_load_times[i]; | 191 hot_sum += hot_load_times[i]; |
| 192 } | 192 } |
| 193 LogPerfResult("Visited_link_cold_load_time", | 193 LogPerfResult("Visited_link_cold_load_time", |
| 194 cold_sum / cold_load_times.size(), "ms"); | 194 cold_sum / cold_load_times.size(), "ms"); |
| 195 LogPerfResult("Visited_link_hot_load_time", | 195 LogPerfResult("Visited_link_hot_load_time", |
| 196 hot_sum / hot_load_times.size(), "ms"); | 196 hot_sum / hot_load_times.size(), "ms"); |
| 197 } | 197 } |
| OLD | NEW |