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 "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_util.h" | 8 #include "base/string_util.h" |
9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
11 #include "base/strings/string_split.h" | 11 #include "base/strings/string_split.h" |
12 #include "base/sys_info.h" | 12 #include "base/sys_info.h" |
13 #include "base/test/test_file_util.h" | 13 #include "base/test/test_file_util.h" |
14 #include "base/test/test_timeouts.h" | 14 #include "base/test/test_timeouts.h" |
15 #include "base/time.h" | 15 #include "base/time.h" |
16 #include "base/utf_string_conversions.h" | 16 #include "base/utf_string_conversions.h" |
17 #include "chrome/common/chrome_constants.h" | 17 #include "chrome/common/chrome_constants.h" |
18 #include "chrome/common/chrome_paths.h" | 18 #include "chrome/common/chrome_paths.h" |
19 #include "chrome/common/chrome_switches.h" | 19 #include "chrome/common/chrome_switches.h" |
20 #include "chrome/common/env_vars.h" | 20 #include "chrome/common/env_vars.h" |
21 #include "chrome/test/automation/automation_proxy.h" | 21 #include "chrome/test/automation/automation_proxy.h" |
22 #include "chrome/test/base/test_switches.h" | 22 #include "chrome/test/base/test_switches.h" |
23 #include "chrome/test/base/testing_profile.h" | 23 #include "chrome/test/base/testing_profile.h" |
24 #include "chrome/test/base/ui_test_utils.h" | 24 #include "chrome/test/base/ui_test_utils.h" |
25 #include "chrome/test/perf/perf_test.h" | 25 #include "chrome/test/perf/perf_test.h" |
| 26 #include "chrome/test/perf/perf_ui_test_suite.h" |
26 #include "chrome/test/ui/ui_perf_test.h" | 27 #include "chrome/test/ui/ui_perf_test.h" |
27 #include "content/public/common/content_switches.h" | 28 #include "content/public/common/content_switches.h" |
28 #include "net/base/net_util.h" | 29 #include "net/base/net_util.h" |
29 | 30 |
30 using base::TimeDelta; | 31 using base::TimeDelta; |
31 using base::TimeTicks; | 32 using base::TimeTicks; |
32 | 33 |
33 namespace { | 34 namespace { |
34 | 35 |
35 class StartupTest : public UIPerfTest { | 36 class StartupTest : public UIPerfTest { |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 base::FilePath data_dir; | 111 base::FilePath data_dir; |
111 PathService::Get(chrome::DIR_TEST_DATA, &data_dir); | 112 PathService::Get(chrome::DIR_TEST_DATA, &data_dir); |
112 data_dir = data_dir.AppendASCII("extensions").AppendASCII("profiles"). | 113 data_dir = data_dir.AppendASCII("extensions").AppendASCII("profiles"). |
113 AppendASCII(profile); | 114 AppendASCII(profile); |
114 set_template_user_data(data_dir); | 115 set_template_user_data(data_dir); |
115 } | 116 } |
116 | 117 |
117 // Rewrite the preferences file to point to the proper image directory. | 118 // Rewrite the preferences file to point to the proper image directory. |
118 virtual void SetUpProfile() OVERRIDE { | 119 virtual void SetUpProfile() OVERRIDE { |
119 UIPerfTest::SetUpProfile(); | 120 UIPerfTest::SetUpProfile(); |
120 if (profile_type_ != UITestBase::COMPLEX_THEME) | 121 if (profile_type_ != PerfUITestSuite::COMPLEX_THEME) |
121 return; | 122 return; |
122 | 123 |
123 const base::FilePath pref_template_path(user_data_dir(). | 124 const base::FilePath pref_template_path(user_data_dir(). |
124 AppendASCII("Default"). | 125 AppendASCII("Default"). |
125 AppendASCII("PreferencesTemplate")); | 126 AppendASCII("PreferencesTemplate")); |
126 const base::FilePath pref_path(user_data_dir(). | 127 const base::FilePath pref_path(user_data_dir(). |
127 AppendASCII(TestingProfile::kTestUserProfileDir). | 128 AppendASCII(TestingProfile::kTestUserProfileDir). |
128 AppendASCII("Preferences")); | 129 AppendASCII("Preferences")); |
129 | 130 |
130 // Read in preferences template. | 131 // Read in preferences template. |
(...skipping 24 matching lines...) Expand all Loading... |
155 | 156 |
156 // Runs a test which loads |tab_count| tabs on startup, either as command line | 157 // Runs a test which loads |tab_count| tabs on startup, either as command line |
157 // arguments or, if |restore_session| is true, by using session restore. | 158 // arguments or, if |restore_session| is true, by using session restore. |
158 // |nth_timed_tab|, if non-zero, will measure time to load the first n+1 tabs. | 159 // |nth_timed_tab|, if non-zero, will measure time to load the first n+1 tabs. |
159 void RunPerfTestWithManyTabs(const char* graph, const char* trace, | 160 void RunPerfTestWithManyTabs(const char* graph, const char* trace, |
160 int tab_count, int nth_timed_tab, | 161 int tab_count, int nth_timed_tab, |
161 bool restore_session); | 162 bool restore_session); |
162 | 163 |
163 void RunStartupTest(const char* graph, const char* trace, | 164 void RunStartupTest(const char* graph, const char* trace, |
164 TestColdness test_cold, TestImportance test_importance, | 165 TestColdness test_cold, TestImportance test_importance, |
165 UITestBase::ProfileType profile_type, | 166 PerfUITestSuite::ProfileType profile_type, |
166 int num_tabs, int nth_timed_tab) { | 167 int num_tabs, int nth_timed_tab) { |
167 bool important = (test_importance == IMPORTANT); | 168 bool important = (test_importance == IMPORTANT); |
168 profile_type_ = profile_type; | 169 profile_type_ = profile_type; |
169 | 170 |
170 // Sets the profile data for the run. For now, this is only used for | 171 // Sets the profile data for the run. For now, this is only used for |
171 // the non-default themes test. | 172 // the non-default themes test. |
172 if (profile_type != UITestBase::DEFAULT_THEME) { | 173 if (profile_type != PerfUITestSuite::DEFAULT_THEME) { |
173 set_template_user_data(UITest::ComputeTypicalUserDataSource( | 174 set_template_user_data( |
174 profile_type)); | 175 PerfUITestSuite::GetPathForProfileType(profile_type)); |
175 } | 176 } |
176 | 177 |
177 #if defined(NDEBUG) | 178 #if defined(NDEBUG) |
178 const int kNumCyclesMax = 20; | 179 const int kNumCyclesMax = 20; |
179 #else | 180 #else |
180 // Debug builds are too slow and we can't run that many cycles in a | 181 // Debug builds are too slow and we can't run that many cycles in a |
181 // reasonable amount of time. | 182 // reasonable amount of time. |
182 const int kNumCyclesMax = 10; | 183 const int kNumCyclesMax = 10; |
183 #endif | 184 #endif |
184 int numCycles = kNumCyclesMax; | 185 int numCycles = kNumCyclesMax; |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 base::StringAppendF(×, "%.2f,", timings[i].last_stop_ms); | 317 base::StringAppendF(×, "%.2f,", timings[i].last_stop_ms); |
317 perf_test::PrintResultList( | 318 perf_test::PrintResultList( |
318 graph, std::string(), name.c_str(), times, "ms", important); | 319 graph, std::string(), name.c_str(), times, "ms", important); |
319 } | 320 } |
320 } | 321 } |
321 } | 322 } |
322 | 323 |
323 base::FilePath profiling_file_; | 324 base::FilePath profiling_file_; |
324 bool collect_profiling_stats_; | 325 bool collect_profiling_stats_; |
325 std::string trace_file_prefix_; | 326 std::string trace_file_prefix_; |
| 327 |
| 328 // Are we using a profile with a complex theme? |
| 329 PerfUITestSuite::ProfileType profile_type_; |
326 }; | 330 }; |
327 | 331 |
328 TEST_F(StartupTest, PerfWarm) { | 332 TEST_F(StartupTest, PerfWarm) { |
329 SetUpWithCompositingDisabledOnMac(); | 333 SetUpWithCompositingDisabledOnMac(); |
330 RunStartupTest("warm", "t", WARM, IMPORTANT, | 334 RunStartupTest("warm", "t", WARM, IMPORTANT, |
331 UITestBase::DEFAULT_THEME, 0, 0); | 335 PerfUITestSuite::DEFAULT_THEME, 0, 0); |
332 } | 336 } |
333 | 337 |
334 #if defined(OS_MACOSX) | 338 #if defined(OS_MACOSX) |
335 TEST_F(StartupTest, PerfWarmFCM) { | 339 TEST_F(StartupTest, PerfWarmFCM) { |
336 SetUpWithCompositingEnabledOnMac(); | 340 SetUpWithCompositingEnabledOnMac(); |
337 RunStartupTest("warm", "t_fcm", WARM, IMPORTANT, | 341 RunStartupTest("warm", "t_fcm", WARM, IMPORTANT, |
338 UITestBase::DEFAULT_THEME, 0, 0); | 342 PerfUITestSuite::DEFAULT_THEME, 0, 0); |
339 } | 343 } |
340 #endif | 344 #endif |
341 | 345 |
342 TEST_F(StartupTest, PerfReferenceWarm) { | 346 TEST_F(StartupTest, PerfReferenceWarm) { |
343 UseReferenceBuild(); | 347 UseReferenceBuild(); |
344 RunStartupTest("warm", "t_ref", WARM, IMPORTANT, | 348 RunStartupTest("warm", "t_ref", WARM, IMPORTANT, |
345 UITestBase::DEFAULT_THEME, 0, 0); | 349 PerfUITestSuite::DEFAULT_THEME, 0, 0); |
346 } | 350 } |
347 | 351 |
348 // TODO(mpcomplete): Should we have reference timings for all these? | 352 // TODO(mpcomplete): Should we have reference timings for all these? |
349 | 353 |
350 // dominich: Disabling as per http://crbug.com/100900. | 354 // dominich: Disabling as per http://crbug.com/100900. |
351 #if defined(OS_WIN) | 355 #if defined(OS_WIN) |
352 #define MAYBE_PerfCold DISABLED_PerfCold | 356 #define MAYBE_PerfCold DISABLED_PerfCold |
353 #else | 357 #else |
354 #define MAYBE_PerfCold PerfCold | 358 #define MAYBE_PerfCold PerfCold |
355 #endif | 359 #endif |
356 | 360 |
357 TEST_F(StartupTest, MAYBE_PerfCold) { | 361 TEST_F(StartupTest, MAYBE_PerfCold) { |
358 SetUpWithCompositingDisabledOnMac(); | 362 SetUpWithCompositingDisabledOnMac(); |
359 RunStartupTest("cold", "t", COLD, NOT_IMPORTANT, | 363 RunStartupTest("cold", "t", COLD, NOT_IMPORTANT, |
360 UITestBase::DEFAULT_THEME, 0, 0); | 364 PerfUITestSuite::DEFAULT_THEME, 0, 0); |
361 } | 365 } |
362 | 366 |
363 #if defined(OS_MACOSX) | 367 #if defined(OS_MACOSX) |
364 TEST_F(StartupTest, PerfColdFCM) { | 368 TEST_F(StartupTest, PerfColdFCM) { |
365 SetUpWithCompositingEnabledOnMac(); | 369 SetUpWithCompositingEnabledOnMac(); |
366 RunStartupTest("cold", "t_fcm", COLD, NOT_IMPORTANT, | 370 RunStartupTest("cold", "t_fcm", COLD, NOT_IMPORTANT, |
367 UITestBase::DEFAULT_THEME, 0, 0); | 371 PerfUITestSuite::DEFAULT_THEME, 0, 0); |
368 } | 372 } |
369 #endif | 373 #endif |
370 | 374 |
371 void StartupTest::RunPerfTestWithManyTabs(const char* graph, const char* trace, | 375 void StartupTest::RunPerfTestWithManyTabs(const char* graph, const char* trace, |
372 int tab_count, int nth_timed_tab, | 376 int tab_count, int nth_timed_tab, |
373 bool restore_session) { | 377 bool restore_session) { |
374 // Initialize session with |tab_count| tabs. | 378 // Initialize session with |tab_count| tabs. |
375 for (int i = 0; i < tab_count; ++i) | 379 for (int i = 0; i < tab_count; ++i) |
376 SetUpWithComplexFileURL(i); | 380 SetUpWithComplexFileURL(i); |
377 | 381 |
(...skipping 16 matching lines...) Expand all Loading... |
394 new_launch_arguments.AppendSwitch(switches::kEnableChromiumBranding); | 398 new_launch_arguments.AppendSwitch(switches::kEnableChromiumBranding); |
395 } | 399 } |
396 // The session will be restored once per cycle for numCycles test cycles, | 400 // The session will be restored once per cycle for numCycles test cycles, |
397 // and each time, UITest::SetUp will wait for |tab_count| tabs to | 401 // and each time, UITest::SetUp will wait for |tab_count| tabs to |
398 // finish loading. | 402 // finish loading. |
399 new_launch_arguments.AppendSwitchASCII(switches::kRestoreLastSession, | 403 new_launch_arguments.AppendSwitchASCII(switches::kRestoreLastSession, |
400 base::IntToString(tab_count)); | 404 base::IntToString(tab_count)); |
401 launch_arguments_ = new_launch_arguments; | 405 launch_arguments_ = new_launch_arguments; |
402 } | 406 } |
403 RunStartupTest(graph, trace, WARM, NOT_IMPORTANT, | 407 RunStartupTest(graph, trace, WARM, NOT_IMPORTANT, |
404 UITestBase::DEFAULT_THEME, tab_count, nth_timed_tab); | 408 PerfUITestSuite::DEFAULT_THEME, tab_count, nth_timed_tab); |
405 } | 409 } |
406 | 410 |
407 // http://crbug.com/101591 | 411 // http://crbug.com/101591 |
408 #if defined(OS_WIN) && !defined(NDEBUG) | 412 #if defined(OS_WIN) && !defined(NDEBUG) |
409 #define MAYBE_PerfFewTabs DISABLED_PerfFewTabs | 413 #define MAYBE_PerfFewTabs DISABLED_PerfFewTabs |
410 #else | 414 #else |
411 #define MAYBE_PerfFewTabs PerfFewTabs | 415 #define MAYBE_PerfFewTabs PerfFewTabs |
412 #endif | 416 #endif |
413 | 417 |
414 TEST_F(StartupTest, MAYBE_PerfFewTabs) { | 418 TEST_F(StartupTest, MAYBE_PerfFewTabs) { |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
494 TEST_F(StartupTest, PerfRestoreSeveralTabsReference) { | 498 TEST_F(StartupTest, PerfRestoreSeveralTabsReference) { |
495 UseReferenceBuild(); | 499 UseReferenceBuild(); |
496 RunPerfTestWithManyTabs("several_tabs", "restore-ref", 10, 4, true); | 500 RunPerfTestWithManyTabs("several_tabs", "restore-ref", 10, 4, true); |
497 } | 501 } |
498 | 502 |
499 TEST_F(StartupTest, PerfExtensionEmpty) { | 503 TEST_F(StartupTest, PerfExtensionEmpty) { |
500 SetUpWithCompositingDisabledOnMac(); | 504 SetUpWithCompositingDisabledOnMac(); |
501 SetUpWithFileURL(); | 505 SetUpWithFileURL(); |
502 SetUpWithExtensionsProfile("empty"); | 506 SetUpWithExtensionsProfile("empty"); |
503 RunStartupTest("warm", "extension_empty", WARM, NOT_IMPORTANT, | 507 RunStartupTest("warm", "extension_empty", WARM, NOT_IMPORTANT, |
504 UITestBase::DEFAULT_THEME, 1, 0); | 508 PerfUITestSuite::DEFAULT_THEME, 1, 0); |
505 } | 509 } |
506 | 510 |
507 #if defined(OS_MACOSX) | 511 #if defined(OS_MACOSX) |
508 TEST_F(StartupTest, PerfExtensionEmptyFCM) { | 512 TEST_F(StartupTest, PerfExtensionEmptyFCM) { |
509 SetUpWithCompositingEnabledOnMac(); | 513 SetUpWithCompositingEnabledOnMac(); |
510 SetUpWithFileURL(); | 514 SetUpWithFileURL(); |
511 SetUpWithExtensionsProfile("empty"); | 515 SetUpWithExtensionsProfile("empty"); |
512 RunStartupTest("warm", "extension_empty_fcm", WARM, NOT_IMPORTANT, | 516 RunStartupTest("warm", "extension_empty_fcm", WARM, NOT_IMPORTANT, |
513 UITestBase::DEFAULT_THEME, 1, 0); | 517 PerfUITestSuite::DEFAULT_THEME, 1, 0); |
514 } | 518 } |
515 #endif | 519 #endif |
516 | 520 |
517 TEST_F(StartupTest, PerfExtensionContentScript1) { | 521 TEST_F(StartupTest, PerfExtensionContentScript1) { |
518 SetUpWithCompositingDisabledOnMac(); | 522 SetUpWithCompositingDisabledOnMac(); |
519 SetUpWithFileURL(); | 523 SetUpWithFileURL(); |
520 SetUpWithExtensionsProfile("content_scripts1"); | 524 SetUpWithExtensionsProfile("content_scripts1"); |
521 RunStartupTest("warm", "extension_content_scripts1", WARM, NOT_IMPORTANT, | 525 RunStartupTest("warm", "extension_content_scripts1", WARM, NOT_IMPORTANT, |
522 UITestBase::DEFAULT_THEME, 1, 0); | 526 PerfUITestSuite::DEFAULT_THEME, 1, 0); |
523 } | 527 } |
524 | 528 |
525 #if defined(OS_MACOSX) | 529 #if defined(OS_MACOSX) |
526 TEST_F(StartupTest, PerfExtensionContentScript1FCM) { | 530 TEST_F(StartupTest, PerfExtensionContentScript1FCM) { |
527 SetUpWithCompositingEnabledOnMac(); | 531 SetUpWithCompositingEnabledOnMac(); |
528 SetUpWithFileURL(); | 532 SetUpWithFileURL(); |
529 SetUpWithExtensionsProfile("content_scripts1"); | 533 SetUpWithExtensionsProfile("content_scripts1"); |
530 RunStartupTest("warm", "extension_content_scripts1_fcm", WARM, NOT_IMPORTANT, | 534 RunStartupTest("warm", "extension_content_scripts1_fcm", WARM, NOT_IMPORTANT, |
531 UITestBase::DEFAULT_THEME, 1, 0); | 535 PerfUITestSuite::DEFAULT_THEME, 1, 0); |
532 } | 536 } |
533 #endif | 537 #endif |
534 | 538 |
535 TEST_F(StartupTest, MAYBE_PerfExtensionContentScript50) { | 539 TEST_F(StartupTest, MAYBE_PerfExtensionContentScript50) { |
536 SetUpWithFileURL(); | 540 SetUpWithFileURL(); |
537 SetUpWithExtensionsProfile("content_scripts50"); | 541 SetUpWithExtensionsProfile("content_scripts50"); |
538 RunStartupTest("warm", "extension_content_scripts50", WARM, NOT_IMPORTANT, | 542 RunStartupTest("warm", "extension_content_scripts50", WARM, NOT_IMPORTANT, |
539 UITestBase::DEFAULT_THEME, 1, 0); | 543 PerfUITestSuite::DEFAULT_THEME, 1, 0); |
540 } | 544 } |
541 | 545 |
542 TEST_F(StartupTest, MAYBE_PerfComplexTheme) { | 546 TEST_F(StartupTest, MAYBE_PerfComplexTheme) { |
543 RunStartupTest("warm", "t-theme", WARM, NOT_IMPORTANT, | 547 RunStartupTest("warm", "t-theme", WARM, NOT_IMPORTANT, |
544 UITestBase::COMPLEX_THEME, 0, 0); | 548 PerfUITestSuite::COMPLEX_THEME, 0, 0); |
545 } | 549 } |
546 | 550 |
547 TEST_F(StartupTest, ProfilingScript1) { | 551 TEST_F(StartupTest, ProfilingScript1) { |
548 SetUpWithCompositingDisabledOnMac(); | 552 SetUpWithCompositingDisabledOnMac(); |
549 SetUpWithFileURL(); | 553 SetUpWithFileURL(); |
550 SetUpWithProfiling(); | 554 SetUpWithProfiling(); |
551 RunStartupTest("warm", "profiling_scripts1", WARM, NOT_IMPORTANT, | 555 RunStartupTest("warm", "profiling_scripts1", WARM, NOT_IMPORTANT, |
552 UITestBase::DEFAULT_THEME, 1, 0); | 556 PerfUITestSuite::DEFAULT_THEME, 1, 0); |
553 } | 557 } |
554 | 558 |
555 #if defined(OS_MACOSX) | 559 #if defined(OS_MACOSX) |
556 TEST_F(StartupTest, ProfilingScript1FCM) { | 560 TEST_F(StartupTest, ProfilingScript1FCM) { |
557 SetUpWithCompositingEnabledOnMac(); | 561 SetUpWithCompositingEnabledOnMac(); |
558 SetUpWithFileURL(); | 562 SetUpWithFileURL(); |
559 SetUpWithProfiling(); | 563 SetUpWithProfiling(); |
560 RunStartupTest("warm", "profiling_scripts1_fcm", WARM, NOT_IMPORTANT, | 564 RunStartupTest("warm", "profiling_scripts1_fcm", WARM, NOT_IMPORTANT, |
561 UITestBase::DEFAULT_THEME, 1, 0); | 565 PerfUITestSuite::DEFAULT_THEME, 1, 0); |
562 } | 566 } |
563 #endif | 567 #endif |
564 | 568 |
565 } // namespace | 569 } // namespace |
OLD | NEW |