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 "base/environment.h" | 5 #include "base/environment.h" |
6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
8 #include "base/string_number_conversions.h" | 8 #include "base/string_number_conversions.h" |
9 #include "base/string_split.h" | 9 #include "base/string_split.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 | 83 |
84 // Runs a test which loads |tab_count| tabs on startup, either as command line | 84 // Runs a test which loads |tab_count| tabs on startup, either as command line |
85 // arguments or, if |restore_session| is true, by using session restore. | 85 // arguments or, if |restore_session| is true, by using session restore. |
86 // |nth_timed_tab|, if non-zero, will measure time to load the first n+1 tabs. | 86 // |nth_timed_tab|, if non-zero, will measure time to load the first n+1 tabs. |
87 void RunPerfTestWithManyTabs(const char* graph, const char* trace, | 87 void RunPerfTestWithManyTabs(const char* graph, const char* trace, |
88 int tab_count, int nth_timed_tab, | 88 int tab_count, int nth_timed_tab, |
89 bool restore_session); | 89 bool restore_session); |
90 | 90 |
91 void RunStartupTest(const char* graph, const char* trace, | 91 void RunStartupTest(const char* graph, const char* trace, |
92 TestColdness test_cold, TestImportance test_importance, | 92 TestColdness test_cold, TestImportance test_importance, |
93 UITest::ProfileType profile_type, | 93 ProxyLauncher::ProfileType profile_type, |
94 int num_tabs, int nth_timed_tab) { | 94 int num_tabs, int nth_timed_tab) { |
95 bool important = (test_importance == IMPORTANT); | 95 bool important = (test_importance == IMPORTANT); |
96 profile_type_ = profile_type; | 96 profile_type_ = profile_type; |
97 | 97 |
98 // Sets the profile data for the run. For now, this is only used for | 98 // Sets the profile data for the run. For now, this is only used for |
99 // the non-default themes test. | 99 // the non-default themes test. |
100 if (profile_type != UITest::DEFAULT_THEME) { | 100 if (profile_type != ProxyLauncher::DEFAULT_THEME) { |
101 set_template_user_data(UITest::ComputeTypicalUserDataSource( | 101 set_template_user_data(UITest::ComputeTypicalUserDataSource( |
102 profile_type)); | 102 profile_type)); |
103 } | 103 } |
104 | 104 |
105 const int kNumCyclesMax = 20; | 105 const int kNumCyclesMax = 20; |
106 int numCycles = kNumCyclesMax; | 106 int numCycles = kNumCyclesMax; |
107 scoped_ptr<base::Environment> env(base::Environment::Create()); | 107 scoped_ptr<base::Environment> env(base::Environment::Create()); |
108 std::string numCyclesEnv; | 108 std::string numCyclesEnv; |
109 if (env->GetVar(env_vars::kStartupTestsNumCycles, &numCyclesEnv) && | 109 if (env->GetVar(env_vars::kStartupTestsNumCycles, &numCyclesEnv) && |
110 base::StringToInt(numCyclesEnv, &numCycles)) { | 110 base::StringToInt(numCyclesEnv, &numCycles)) { |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 timings[i].first_start_ms = min_start; | 180 timings[i].first_start_ms = min_start; |
181 timings[i].last_stop_ms = max_stop; | 181 timings[i].last_stop_ms = max_stop; |
182 timings[i].first_stop_ms = times[0]; | 182 timings[i].first_stop_ms = times[0]; |
183 timings[i].nth_tab_stop_ms = times[nth_timed_tab]; | 183 timings[i].nth_tab_stop_ms = times[nth_timed_tab]; |
184 } else { | 184 } else { |
185 // Browser might not support initial load times. | 185 // Browser might not support initial load times. |
186 // Only use end-to-end time for this test. | 186 // Only use end-to-end time for this test. |
187 num_tabs = 0; | 187 num_tabs = 0; |
188 } | 188 } |
189 } | 189 } |
190 timings[i].end_to_end = end_time - browser_launch_time_; | 190 timings[i].end_to_end = end_time - browser_launch_time(); |
191 UITest::TearDown(); | 191 UITest::TearDown(); |
192 | 192 |
193 if (i == 0) { | 193 if (i == 0) { |
194 // Re-use the profile data after first run so that the noise from | 194 // Re-use the profile data after first run so that the noise from |
195 // creating databases doesn't impact all the runs. | 195 // creating databases doesn't impact all the runs. |
196 clear_profile_ = false; | 196 clear_profile_ = false; |
197 // Clear template_user_data_ so we don't try to copy it over each time | 197 // Clear template_user_data_ so we don't try to copy it over each time |
198 // through. | 198 // through. |
199 set_template_user_data(FilePath()); | 199 set_template_user_data(FilePath()); |
200 } | 200 } |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 name = name_base + "-all"; | 239 name = name_base + "-all"; |
240 for (int i = 0; i < numCycles; ++i) | 240 for (int i = 0; i < numCycles; ++i) |
241 base::StringAppendF(×, "%.2f,", timings[i].last_stop_ms); | 241 base::StringAppendF(×, "%.2f,", timings[i].last_stop_ms); |
242 PrintResultList(graph, "", name.c_str(), times, "ms", important); | 242 PrintResultList(graph, "", name.c_str(), times, "ms", important); |
243 } | 243 } |
244 } | 244 } |
245 } | 245 } |
246 }; | 246 }; |
247 | 247 |
248 TEST_F(StartupTest, PerfWarm) { | 248 TEST_F(StartupTest, PerfWarm) { |
249 RunStartupTest("warm", "t", WARM, IMPORTANT, UITest::DEFAULT_THEME, 0, 0); | 249 RunStartupTest("warm", "t", WARM, IMPORTANT, |
| 250 ProxyLauncher::DEFAULT_THEME, 0, 0); |
250 } | 251 } |
251 | 252 |
252 TEST_F(StartupTest, PerfReferenceWarm) { | 253 TEST_F(StartupTest, PerfReferenceWarm) { |
253 UseReferenceBuild(); | 254 UseReferenceBuild(); |
254 RunStartupTest("warm", "t_ref", WARM, IMPORTANT, UITest::DEFAULT_THEME, 0, 0); | 255 RunStartupTest("warm", "t_ref", WARM, IMPORTANT, |
| 256 ProxyLauncher::DEFAULT_THEME, 0, 0); |
255 } | 257 } |
256 | 258 |
257 // TODO(mpcomplete): Should we have reference timings for all these? | 259 // TODO(mpcomplete): Should we have reference timings for all these? |
258 | 260 |
259 TEST_F(StartupTest, PerfCold) { | 261 TEST_F(StartupTest, PerfCold) { |
260 RunStartupTest("cold", "t", COLD, NOT_IMPORTANT, UITest::DEFAULT_THEME, 0, 0); | 262 RunStartupTest("cold", "t", COLD, NOT_IMPORTANT, |
| 263 ProxyLauncher::DEFAULT_THEME, 0, 0); |
261 } | 264 } |
262 | 265 |
263 void StartupTest::RunPerfTestWithManyTabs(const char* graph, const char* trace, | 266 void StartupTest::RunPerfTestWithManyTabs(const char* graph, const char* trace, |
264 int tab_count, int nth_timed_tab, | 267 int tab_count, int nth_timed_tab, |
265 bool restore_session) { | 268 bool restore_session) { |
266 // Initialize session with |tab_count| tabs. | 269 // Initialize session with |tab_count| tabs. |
267 for (int i = 0; i < tab_count; ++i) | 270 for (int i = 0; i < tab_count; ++i) |
268 SetUpWithComplexFileURL(i); | 271 SetUpWithComplexFileURL(i); |
269 | 272 |
270 if (restore_session) { | 273 if (restore_session) { |
271 // Start the browser with these urls so we can save the session and exit. | 274 // Start the browser with these urls so we can save the session and exit. |
272 UITest::SetUp(); | 275 UITest::SetUp(); |
273 // Set flags to ensure profile is saved and can be restored. | 276 // Set flags to ensure profile is saved and can be restored. |
274 #if defined(OS_MACOSX) | 277 #if defined(OS_MACOSX) |
275 shutdown_type_ = UITestBase::USER_QUIT; | 278 shutdown_type_ = ProxyLauncher::USER_QUIT; |
276 #endif | 279 #endif |
277 clear_profile_ = false; | 280 clear_profile_ = false; |
278 // Quit and set flags to restore session. | 281 // Quit and set flags to restore session. |
279 UITest::TearDown(); | 282 UITest::TearDown(); |
280 // Clear all arguments for session restore, or the number of open tabs | 283 // Clear all arguments for session restore, or the number of open tabs |
281 // will grow with each restore. | 284 // will grow with each restore. |
282 launch_arguments_ = CommandLine(CommandLine::NO_PROGRAM); | 285 launch_arguments_ = CommandLine(CommandLine::NO_PROGRAM); |
283 // The session will be restored once per cycle for numCycles test cycles, | 286 // The session will be restored once per cycle for numCycles test cycles, |
284 // and each time, UITest::SetUp will wait for |tab_count| tabs to | 287 // and each time, UITest::SetUp will wait for |tab_count| tabs to |
285 // finish loading. | 288 // finish loading. |
286 launch_arguments_.AppendSwitchASCII(switches::kRestoreLastSession, | 289 launch_arguments_.AppendSwitchASCII(switches::kRestoreLastSession, |
287 base::IntToString(tab_count)); | 290 base::IntToString(tab_count)); |
288 } | 291 } |
289 RunStartupTest(graph, trace, WARM, NOT_IMPORTANT, UITest::DEFAULT_THEME, | 292 RunStartupTest(graph, trace, WARM, NOT_IMPORTANT, |
290 tab_count, nth_timed_tab); | 293 ProxyLauncher::DEFAULT_THEME, tab_count, nth_timed_tab); |
291 } | 294 } |
292 | 295 |
293 TEST_F(StartupTest, PerfFewTabs) { | 296 TEST_F(StartupTest, PerfFewTabs) { |
294 RunPerfTestWithManyTabs("few_tabs", "cmdline", 5, 2, false); | 297 RunPerfTestWithManyTabs("few_tabs", "cmdline", 5, 2, false); |
295 } | 298 } |
296 | 299 |
297 TEST_F(StartupTest, PerfFewTabsReference) { | 300 TEST_F(StartupTest, PerfFewTabsReference) { |
298 UseReferenceBuild(); | 301 UseReferenceBuild(); |
299 RunPerfTestWithManyTabs("few_tabs", "cmdline-ref", 5, 2, false); | 302 RunPerfTestWithManyTabs("few_tabs", "cmdline-ref", 5, 2, false); |
300 } | 303 } |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 | 346 |
344 TEST_F(StartupTest, PerfRestoreSeveralTabsReference) { | 347 TEST_F(StartupTest, PerfRestoreSeveralTabsReference) { |
345 UseReferenceBuild(); | 348 UseReferenceBuild(); |
346 RunPerfTestWithManyTabs("several_tabs", "restore-ref", 10, 4, true); | 349 RunPerfTestWithManyTabs("several_tabs", "restore-ref", 10, 4, true); |
347 } | 350 } |
348 | 351 |
349 TEST_F(StartupTest, PerfExtensionEmpty) { | 352 TEST_F(StartupTest, PerfExtensionEmpty) { |
350 SetUpWithFileURL(); | 353 SetUpWithFileURL(); |
351 SetUpWithExtensionsProfile("empty"); | 354 SetUpWithExtensionsProfile("empty"); |
352 RunStartupTest("warm", "extension_empty", WARM, NOT_IMPORTANT, | 355 RunStartupTest("warm", "extension_empty", WARM, NOT_IMPORTANT, |
353 UITest::DEFAULT_THEME, 1, 0); | 356 ProxyLauncher::DEFAULT_THEME, 1, 0); |
354 } | 357 } |
355 | 358 |
356 TEST_F(StartupTest, PerfExtensionContentScript1) { | 359 TEST_F(StartupTest, PerfExtensionContentScript1) { |
357 SetUpWithFileURL(); | 360 SetUpWithFileURL(); |
358 SetUpWithExtensionsProfile("content_scripts1"); | 361 SetUpWithExtensionsProfile("content_scripts1"); |
359 RunStartupTest("warm", "extension_content_scripts1", WARM, NOT_IMPORTANT, | 362 RunStartupTest("warm", "extension_content_scripts1", WARM, NOT_IMPORTANT, |
360 UITest::DEFAULT_THEME, 1, 0); | 363 ProxyLauncher::DEFAULT_THEME, 1, 0); |
361 } | 364 } |
362 | 365 |
363 TEST_F(StartupTest, MAYBE_PerfExtensionContentScript50) { | 366 TEST_F(StartupTest, MAYBE_PerfExtensionContentScript50) { |
364 SetUpWithFileURL(); | 367 SetUpWithFileURL(); |
365 SetUpWithExtensionsProfile("content_scripts50"); | 368 SetUpWithExtensionsProfile("content_scripts50"); |
366 RunStartupTest("warm", "extension_content_scripts50", WARM, NOT_IMPORTANT, | 369 RunStartupTest("warm", "extension_content_scripts50", WARM, NOT_IMPORTANT, |
367 UITest::DEFAULT_THEME, 1, 0); | 370 ProxyLauncher::DEFAULT_THEME, 1, 0); |
368 } | 371 } |
369 | 372 |
370 #if defined(OS_WIN) | 373 #if defined(OS_WIN) |
371 // TODO(port): Enable gears tests on linux/mac once gears is working. | 374 // TODO(port): Enable gears tests on linux/mac once gears is working. |
372 TEST_F(StartupTest, PerfGears) { | 375 TEST_F(StartupTest, PerfGears) { |
373 SetUpWithFileURL(); | 376 SetUpWithFileURL(); |
374 RunStartupTest("warm", "gears", WARM, NOT_IMPORTANT, | 377 RunStartupTest("warm", "gears", WARM, NOT_IMPORTANT, |
375 UITest::DEFAULT_THEME, 1, 0); | 378 ProxyLauncher::DEFAULT_THEME, 1, 0); |
376 } | 379 } |
377 | 380 |
378 TEST_F(StartupTest, PerfColdGears) { | 381 TEST_F(StartupTest, PerfColdGears) { |
379 SetUpWithFileURL(); | 382 SetUpWithFileURL(); |
380 RunStartupTest("cold", "gears", COLD, NOT_IMPORTANT, | 383 RunStartupTest("cold", "gears", COLD, NOT_IMPORTANT, |
381 UITest::DEFAULT_THEME, 1, 0); | 384 ProxyLauncher::DEFAULT_THEME, 1, 0); |
382 } | 385 } |
383 #endif | 386 #endif |
384 | 387 |
385 TEST_F(StartupTest, PerfComplexTheme) { | 388 TEST_F(StartupTest, PerfComplexTheme) { |
386 RunStartupTest("warm", "t-theme", WARM, NOT_IMPORTANT, | 389 RunStartupTest("warm", "t-theme", WARM, NOT_IMPORTANT, |
387 UITest::COMPLEX_THEME, 0, 0); | 390 ProxyLauncher::COMPLEX_THEME, 0, 0); |
388 } | 391 } |
389 | 392 |
390 #if defined(OS_LINUX) | 393 #if defined(OS_LINUX) |
391 TEST_F(StartupTest, PerfGtkTheme) { | 394 TEST_F(StartupTest, PerfGtkTheme) { |
392 RunStartupTest("warm", "gtk-theme", WARM, NOT_IMPORTANT, | 395 RunStartupTest("warm", "gtk-theme", WARM, NOT_IMPORTANT, |
393 UITest::NATIVE_THEME, 0, 0); | 396 ProxyLauncher::NATIVE_THEME, 0, 0); |
394 } | 397 } |
395 | 398 |
396 TEST_F(StartupTest, PrefNativeFrame) { | 399 TEST_F(StartupTest, PrefNativeFrame) { |
397 RunStartupTest("warm", "custom-frame", WARM, NOT_IMPORTANT, | 400 RunStartupTest("warm", "custom-frame", WARM, NOT_IMPORTANT, |
398 UITest::CUSTOM_FRAME, 0, 0); | 401 ProxyLauncher::CUSTOM_FRAME, 0, 0); |
399 } | 402 } |
400 | 403 |
401 TEST_F(StartupTest, PerfNativeFrameGtkTheme) { | 404 TEST_F(StartupTest, PerfNativeFrameGtkTheme) { |
402 RunStartupTest("warm", "custom-frame-gtk-theme", WARM, NOT_IMPORTANT, | 405 RunStartupTest("warm", "custom-frame-gtk-theme", WARM, NOT_IMPORTANT, |
403 UITest::CUSTOM_FRAME_NATIVE_THEME, 0, 0); | 406 ProxyLauncher::CUSTOM_FRAME_NATIVE_THEME, 0, 0); |
404 } | 407 } |
405 #endif | 408 #endif |
406 | 409 |
407 } // namespace | 410 } // namespace |
OLD | NEW |