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