OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/test/perf/generate_profile.h" | 5 #include "chrome/test/perf/generate_profile.h" |
6 | 6 |
7 #include "base/at_exit.h" | 7 #include "base/at_exit.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/files/file_enumerator.h" | 10 #include "base/files/file_enumerator.h" |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 GURL ConstructRandomURL() { | 107 GURL ConstructRandomURL() { |
108 return GURL(ASCIIToUTF16("http://") + RandomChars(3) + ASCIIToUTF16(".com/") + | 108 return GURL(ASCIIToUTF16("http://") + RandomChars(3) + ASCIIToUTF16(".com/") + |
109 RandomChars(RandomInt(5, 20))); | 109 RandomChars(RandomInt(5, 20))); |
110 } | 110 } |
111 | 111 |
112 // Return a random page title-looking string. | 112 // Return a random page title-looking string. |
113 string16 ConstructRandomTitle() { | 113 string16 ConstructRandomTitle() { |
114 return RandomWords(RandomInt(3, 15)); | 114 return RandomWords(RandomInt(3, 15)); |
115 } | 115 } |
116 | 116 |
117 // Return a random string that could function as page contents. | |
118 string16 ConstructRandomPage() { | |
119 return RandomWords(RandomInt(10, 4000)); | |
120 } | |
121 | |
122 // Insert a batch of |batch_size| URLs, starting at pageid |page_id|. | 117 // Insert a batch of |batch_size| URLs, starting at pageid |page_id|. |
123 void InsertURLBatch(Profile* profile, | 118 void InsertURLBatch(Profile* profile, |
124 int page_id, | 119 int page_id, |
125 int batch_size, | 120 int batch_size, |
126 int types) { | 121 int types) { |
127 HistoryService* history_service = | 122 HistoryService* history_service = |
128 HistoryServiceFactory::GetForProfile(profile, Profile::EXPLICIT_ACCESS); | 123 HistoryServiceFactory::GetForProfile(profile, Profile::EXPLICIT_ACCESS); |
129 | 124 |
130 // Probability of following a link on the current "page" | 125 // Probability of following a link on the current "page" |
131 // (vs randomly jumping to a new page). | 126 // (vs randomly jumping to a new page). |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 path = file_iterator.Next(); | 259 path = file_iterator.Next(); |
265 } | 260 } |
266 | 261 |
267 printf("Finished creating profiles for testing.\n"); | 262 printf("Finished creating profiles for testing.\n"); |
268 | 263 |
269 // Restore the random seed. | 264 // Restore the random seed. |
270 srand(static_cast<unsigned int>(Time::Now().ToInternalValue())); | 265 srand(static_cast<unsigned int>(Time::Now().ToInternalValue())); |
271 | 266 |
272 return true; | 267 return true; |
273 } | 268 } |
OLD | NEW |