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 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 if (revisit_urls.empty() || RandomFloat() < kRevisitableURLProbability) | 198 if (revisit_urls.empty() || RandomFloat() < kRevisitableURLProbability) |
199 revisit_urls.push_back(url); | 199 revisit_urls.push_back(url); |
200 } | 200 } |
201 } | 201 } |
202 | 202 |
203 } // namespace | 203 } // namespace |
204 | 204 |
205 bool GenerateProfile(GenerateProfileTypes types, | 205 bool GenerateProfile(GenerateProfileTypes types, |
206 int url_count, | 206 int url_count, |
207 const base::FilePath& dst_dir) { | 207 const base::FilePath& dst_dir) { |
208 if (!file_util::CreateDirectory(dst_dir)) { | 208 if (!base::CreateDirectory(dst_dir)) { |
209 PLOG(ERROR) << "Unable to create directory " << dst_dir.value().c_str(); | 209 PLOG(ERROR) << "Unable to create directory " << dst_dir.value().c_str(); |
210 return false; | 210 return false; |
211 } | 211 } |
212 | 212 |
213 // We want this profile to be as deterministic as possible, so seed the | 213 // We want this profile to be as deterministic as possible, so seed the |
214 // random number generator with the number of urls we're generating. | 214 // random number generator with the number of urls we're generating. |
215 srand(static_cast<unsigned int>(url_count)); | 215 srand(static_cast<unsigned int>(url_count)); |
216 | 216 |
217 printf("Creating profiles for testing...\n"); | 217 printf("Creating profiles for testing...\n"); |
218 | 218 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 path = file_iterator.Next(); | 259 path = file_iterator.Next(); |
260 } | 260 } |
261 | 261 |
262 printf("Finished creating profiles for testing.\n"); | 262 printf("Finished creating profiles for testing.\n"); |
263 | 263 |
264 // Restore the random seed. | 264 // Restore the random seed. |
265 srand(static_cast<unsigned int>(Time::Now().ToInternalValue())); | 265 srand(static_cast<unsigned int>(Time::Now().ToInternalValue())); |
266 | 266 |
267 return true; | 267 return true; |
268 } | 268 } |
OLD | NEW |