| 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 base::FilePath data_dir; | 97 base::FilePath data_dir; |
| 97 PathService::Get(chrome::DIR_TEST_DATA, &data_dir); | 98 PathService::Get(chrome::DIR_TEST_DATA, &data_dir); |
| 98 data_dir = data_dir.AppendASCII("extensions").AppendASCII("profiles"). | 99 data_dir = data_dir.AppendASCII("extensions").AppendASCII("profiles"). |
| 99 AppendASCII(profile); | 100 AppendASCII(profile); |
| 100 set_template_user_data(data_dir); | 101 set_template_user_data(data_dir); |
| 101 } | 102 } |
| 102 | 103 |
| 103 // Rewrite the preferences file to point to the proper image directory. | 104 // Rewrite the preferences file to point to the proper image directory. |
| 104 virtual void SetUpProfile() OVERRIDE { | 105 virtual void SetUpProfile() OVERRIDE { |
| 105 UIPerfTest::SetUpProfile(); | 106 UIPerfTest::SetUpProfile(); |
| 106 if (profile_type_ != UITestBase::COMPLEX_THEME) | 107 if (profile_type_ != PerfUITestSuite::COMPLEX_THEME) |
| 107 return; | 108 return; |
| 108 | 109 |
| 109 const base::FilePath pref_template_path(user_data_dir(). | 110 const base::FilePath pref_template_path(user_data_dir(). |
| 110 AppendASCII("Default"). | 111 AppendASCII("Default"). |
| 111 AppendASCII("PreferencesTemplate")); | 112 AppendASCII("PreferencesTemplate")); |
| 112 const base::FilePath pref_path(user_data_dir(). | 113 const base::FilePath pref_path(user_data_dir(). |
| 113 AppendASCII(TestingProfile::kTestUserProfileDir). | 114 AppendASCII(TestingProfile::kTestUserProfileDir). |
| 114 AppendASCII("Preferences")); | 115 AppendASCII("Preferences")); |
| 115 | 116 |
| 116 // Read in preferences template. | 117 // Read in preferences template. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 141 | 142 |
| 142 // Runs a test which loads |tab_count| tabs on startup, either as command line | 143 // Runs a test which loads |tab_count| tabs on startup, either as command line |
| 143 // arguments or, if |restore_session| is true, by using session restore. | 144 // arguments or, if |restore_session| is true, by using session restore. |
| 144 // |nth_timed_tab|, if non-zero, will measure time to load the first n+1 tabs. | 145 // |nth_timed_tab|, if non-zero, will measure time to load the first n+1 tabs. |
| 145 void RunPerfTestWithManyTabs(const char* graph, const char* trace, | 146 void RunPerfTestWithManyTabs(const char* graph, const char* trace, |
| 146 int tab_count, int nth_timed_tab, | 147 int tab_count, int nth_timed_tab, |
| 147 bool restore_session); | 148 bool restore_session); |
| 148 | 149 |
| 149 void RunStartupTest(const char* graph, const char* trace, | 150 void RunStartupTest(const char* graph, const char* trace, |
| 150 TestColdness test_cold, TestImportance test_importance, | 151 TestColdness test_cold, TestImportance test_importance, |
| 151 UITestBase::ProfileType profile_type, | 152 PerfUITestSuite::ProfileType profile_type, |
| 152 int num_tabs, int nth_timed_tab) { | 153 int num_tabs, int nth_timed_tab) { |
| 153 bool important = (test_importance == IMPORTANT); | 154 bool important = (test_importance == IMPORTANT); |
| 154 profile_type_ = profile_type; | 155 profile_type_ = profile_type; |
| 155 | 156 |
| 156 // Sets the profile data for the run. For now, this is only used for | 157 // Sets the profile data for the run. For now, this is only used for |
| 157 // the non-default themes test. | 158 // the non-default themes test. |
| 158 if (profile_type != UITestBase::DEFAULT_THEME) { | 159 if (profile_type != PerfUITestSuite::DEFAULT_THEME) { |
| 159 set_template_user_data(UITest::ComputeTypicalUserDataSource( | 160 set_template_user_data( |
| 160 profile_type)); | 161 PerfUITestSuite::GetPathForProfileType(profile_type)); |
| 161 } | 162 } |
| 162 | 163 |
| 163 #if defined(NDEBUG) | 164 #if defined(NDEBUG) |
| 164 const int kNumCyclesMax = 20; | 165 const int kNumCyclesMax = 20; |
| 165 #else | 166 #else |
| 166 // Debug builds are too slow and we can't run that many cycles in a | 167 // Debug builds are too slow and we can't run that many cycles in a |
| 167 // reasonable amount of time. | 168 // reasonable amount of time. |
| 168 const int kNumCyclesMax = 10; | 169 const int kNumCyclesMax = 10; |
| 169 #endif | 170 #endif |
| 170 int numCycles = kNumCyclesMax; | 171 int numCycles = kNumCyclesMax; |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 base::StringAppendF(×, "%.2f,", timings[i].last_stop_ms); | 295 base::StringAppendF(×, "%.2f,", timings[i].last_stop_ms); |
| 295 perf_test::PrintResultList( | 296 perf_test::PrintResultList( |
| 296 graph, std::string(), name.c_str(), times, "ms", important); | 297 graph, std::string(), name.c_str(), times, "ms", important); |
| 297 } | 298 } |
| 298 } | 299 } |
| 299 } | 300 } |
| 300 | 301 |
| 301 base::FilePath profiling_file_; | 302 base::FilePath profiling_file_; |
| 302 bool collect_profiling_stats_; | 303 bool collect_profiling_stats_; |
| 303 std::string trace_file_prefix_; | 304 std::string trace_file_prefix_; |
| 305 |
| 306 // Are we using a profile with a complex theme? |
| 307 PerfUITestSuite::ProfileType profile_type_; |
| 304 }; | 308 }; |
| 305 | 309 |
| 306 TEST_F(StartupTest, PerfWarm) { | 310 TEST_F(StartupTest, PerfWarm) { |
| 307 RunStartupTest("warm", "t", WARM, IMPORTANT, | 311 RunStartupTest("warm", "t", WARM, IMPORTANT, |
| 308 UITestBase::DEFAULT_THEME, 0, 0); | 312 PerfUITestSuite::DEFAULT_THEME, 0, 0); |
| 309 } | 313 } |
| 310 | 314 |
| 311 TEST_F(StartupTest, PerfReferenceWarm) { | 315 TEST_F(StartupTest, PerfReferenceWarm) { |
| 312 UseReferenceBuild(); | 316 UseReferenceBuild(); |
| 313 RunStartupTest("warm", "t_ref", WARM, IMPORTANT, | 317 RunStartupTest("warm", "t_ref", WARM, IMPORTANT, |
| 314 UITestBase::DEFAULT_THEME, 0, 0); | 318 PerfUITestSuite::DEFAULT_THEME, 0, 0); |
| 315 } | 319 } |
| 316 | 320 |
| 317 // TODO(mpcomplete): Should we have reference timings for all these? | 321 // TODO(mpcomplete): Should we have reference timings for all these? |
| 318 | 322 |
| 319 // dominich: Disabling as per http://crbug.com/100900. | 323 // dominich: Disabling as per http://crbug.com/100900. |
| 320 #if defined(OS_WIN) | 324 #if defined(OS_WIN) |
| 321 #define MAYBE_PerfCold DISABLED_PerfCold | 325 #define MAYBE_PerfCold DISABLED_PerfCold |
| 322 #else | 326 #else |
| 323 #define MAYBE_PerfCold PerfCold | 327 #define MAYBE_PerfCold PerfCold |
| 324 #endif | 328 #endif |
| 325 | 329 |
| 326 TEST_F(StartupTest, MAYBE_PerfCold) { | 330 TEST_F(StartupTest, MAYBE_PerfCold) { |
| 327 RunStartupTest("cold", "t", COLD, NOT_IMPORTANT, | 331 RunStartupTest("cold", "t", COLD, NOT_IMPORTANT, |
| 328 UITestBase::DEFAULT_THEME, 0, 0); | 332 PerfUITestSuite::DEFAULT_THEME, 0, 0); |
| 329 } | 333 } |
| 330 | 334 |
| 331 void StartupTest::RunPerfTestWithManyTabs(const char* graph, const char* trace, | 335 void StartupTest::RunPerfTestWithManyTabs(const char* graph, const char* trace, |
| 332 int tab_count, int nth_timed_tab, | 336 int tab_count, int nth_timed_tab, |
| 333 bool restore_session) { | 337 bool restore_session) { |
| 334 // Initialize session with |tab_count| tabs. | 338 // Initialize session with |tab_count| tabs. |
| 335 for (int i = 0; i < tab_count; ++i) | 339 for (int i = 0; i < tab_count; ++i) |
| 336 SetUpWithComplexFileURL(i); | 340 SetUpWithComplexFileURL(i); |
| 337 | 341 |
| 338 if (restore_session) { | 342 if (restore_session) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 354 new_launch_arguments.AppendSwitch(switches::kEnableChromiumBranding); | 358 new_launch_arguments.AppendSwitch(switches::kEnableChromiumBranding); |
| 355 } | 359 } |
| 356 // The session will be restored once per cycle for numCycles test cycles, | 360 // The session will be restored once per cycle for numCycles test cycles, |
| 357 // and each time, UITest::SetUp will wait for |tab_count| tabs to | 361 // and each time, UITest::SetUp will wait for |tab_count| tabs to |
| 358 // finish loading. | 362 // finish loading. |
| 359 new_launch_arguments.AppendSwitchASCII(switches::kRestoreLastSession, | 363 new_launch_arguments.AppendSwitchASCII(switches::kRestoreLastSession, |
| 360 base::IntToString(tab_count)); | 364 base::IntToString(tab_count)); |
| 361 launch_arguments_ = new_launch_arguments; | 365 launch_arguments_ = new_launch_arguments; |
| 362 } | 366 } |
| 363 RunStartupTest(graph, trace, WARM, NOT_IMPORTANT, | 367 RunStartupTest(graph, trace, WARM, NOT_IMPORTANT, |
| 364 UITestBase::DEFAULT_THEME, tab_count, nth_timed_tab); | 368 PerfUITestSuite::DEFAULT_THEME, tab_count, nth_timed_tab); |
| 365 } | 369 } |
| 366 | 370 |
| 367 // http://crbug.com/101591 | 371 // http://crbug.com/101591 |
| 368 #if defined(OS_WIN) && !defined(NDEBUG) | 372 #if defined(OS_WIN) && !defined(NDEBUG) |
| 369 #define MAYBE_PerfFewTabs DISABLED_PerfFewTabs | 373 #define MAYBE_PerfFewTabs DISABLED_PerfFewTabs |
| 370 #else | 374 #else |
| 371 #define MAYBE_PerfFewTabs PerfFewTabs | 375 #define MAYBE_PerfFewTabs PerfFewTabs |
| 372 #endif | 376 #endif |
| 373 | 377 |
| 374 TEST_F(StartupTest, MAYBE_PerfFewTabs) { | 378 TEST_F(StartupTest, MAYBE_PerfFewTabs) { |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 437 | 441 |
| 438 TEST_F(StartupTest, PerfRestoreSeveralTabsReference) { | 442 TEST_F(StartupTest, PerfRestoreSeveralTabsReference) { |
| 439 UseReferenceBuild(); | 443 UseReferenceBuild(); |
| 440 RunPerfTestWithManyTabs("several_tabs", "restore-ref", 10, 4, true); | 444 RunPerfTestWithManyTabs("several_tabs", "restore-ref", 10, 4, true); |
| 441 } | 445 } |
| 442 | 446 |
| 443 TEST_F(StartupTest, PerfExtensionEmpty) { | 447 TEST_F(StartupTest, PerfExtensionEmpty) { |
| 444 SetUpWithFileURL(); | 448 SetUpWithFileURL(); |
| 445 SetUpWithExtensionsProfile("empty"); | 449 SetUpWithExtensionsProfile("empty"); |
| 446 RunStartupTest("warm", "extension_empty", WARM, NOT_IMPORTANT, | 450 RunStartupTest("warm", "extension_empty", WARM, NOT_IMPORTANT, |
| 447 UITestBase::DEFAULT_THEME, 1, 0); | 451 PerfUITestSuite::DEFAULT_THEME, 1, 0); |
| 448 } | 452 } |
| 449 | 453 |
| 450 TEST_F(StartupTest, PerfExtensionContentScript1) { | 454 TEST_F(StartupTest, PerfExtensionContentScript1) { |
| 451 SetUpWithFileURL(); | 455 SetUpWithFileURL(); |
| 452 SetUpWithExtensionsProfile("content_scripts1"); | 456 SetUpWithExtensionsProfile("content_scripts1"); |
| 453 RunStartupTest("warm", "extension_content_scripts1", WARM, NOT_IMPORTANT, | 457 RunStartupTest("warm", "extension_content_scripts1", WARM, NOT_IMPORTANT, |
| 454 UITestBase::DEFAULT_THEME, 1, 0); | 458 PerfUITestSuite::DEFAULT_THEME, 1, 0); |
| 455 } | 459 } |
| 456 | 460 |
| 457 TEST_F(StartupTest, MAYBE_PerfExtensionContentScript50) { | 461 TEST_F(StartupTest, MAYBE_PerfExtensionContentScript50) { |
| 458 SetUpWithFileURL(); | 462 SetUpWithFileURL(); |
| 459 SetUpWithExtensionsProfile("content_scripts50"); | 463 SetUpWithExtensionsProfile("content_scripts50"); |
| 460 RunStartupTest("warm", "extension_content_scripts50", WARM, NOT_IMPORTANT, | 464 RunStartupTest("warm", "extension_content_scripts50", WARM, NOT_IMPORTANT, |
| 461 UITestBase::DEFAULT_THEME, 1, 0); | 465 PerfUITestSuite::DEFAULT_THEME, 1, 0); |
| 462 } | 466 } |
| 463 | 467 |
| 464 TEST_F(StartupTest, MAYBE_PerfComplexTheme) { | 468 TEST_F(StartupTest, MAYBE_PerfComplexTheme) { |
| 465 RunStartupTest("warm", "t-theme", WARM, NOT_IMPORTANT, | 469 RunStartupTest("warm", "t-theme", WARM, NOT_IMPORTANT, |
| 466 UITestBase::COMPLEX_THEME, 0, 0); | 470 PerfUITestSuite::COMPLEX_THEME, 0, 0); |
| 467 } | 471 } |
| 468 | 472 |
| 469 TEST_F(StartupTest, ProfilingScript1) { | 473 TEST_F(StartupTest, ProfilingScript1) { |
| 470 SetUpWithFileURL(); | 474 SetUpWithFileURL(); |
| 471 SetUpWithProfiling(); | 475 SetUpWithProfiling(); |
| 472 RunStartupTest("warm", "profiling_scripts1", WARM, NOT_IMPORTANT, | 476 RunStartupTest("warm", "profiling_scripts1", WARM, NOT_IMPORTANT, |
| 473 UITestBase::DEFAULT_THEME, 1, 0); | 477 PerfUITestSuite::DEFAULT_THEME, 1, 0); |
| 474 } | 478 } |
| 475 | 479 |
| 476 } // namespace | 480 } // namespace |
| OLD | NEW |