Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(175)

Side by Side Diff: chrome/test/perf/page_cycler_test.cc

Issue 9956045: Add Web Page Replay test to page cycler. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Ready for review. Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | tools/page_cycler/common/head.js » ('j') | tools/page_cycler/common/report.html » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/command_line.h" 6 #include "base/command_line.h"
7 #include "base/file_path.h" 7 #include "base/file_path.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "base/process_util.h" 10 #include "base/process_util.h"
(...skipping 11 matching lines...) Expand all
22 #include "chrome/test/base/chrome_process_util.h" 22 #include "chrome/test/base/chrome_process_util.h"
23 #include "chrome/test/base/test_switches.h" 23 #include "chrome/test/base/test_switches.h"
24 #include "chrome/test/perf/perf_test.h" 24 #include "chrome/test/perf/perf_test.h"
25 #include "chrome/test/ui/ui_perf_test.h" 25 #include "chrome/test/ui/ui_perf_test.h"
26 #include "googleurl/src/gurl.h" 26 #include "googleurl/src/gurl.h"
27 #include "net/base/net_util.h" 27 #include "net/base/net_util.h"
28 28
29 #ifndef NDEBUG 29 #ifndef NDEBUG
30 static const int kTestIterations = 2; 30 static const int kTestIterations = 2;
31 static const int kDatabaseTestIterations = 2; 31 static const int kDatabaseTestIterations = 2;
32 static const int kWebPageReplayIterations = 2;
32 #else 33 #else
33 static const int kTestIterations = 10; 34 static const int kTestIterations = 10;
34 // For some unknown reason, the DB perf tests are much much slower on the 35 // For some unknown reason, the DB perf tests are much much slower on the
35 // Vista perf bot, so we have to cut down the number of iterations to 5 36 // Vista perf bot, so we have to cut down the number of iterations to 5
36 // to make sure each test finishes in less than 10 minutes. 37 // to make sure each test finishes in less than 10 minutes.
37 static const int kDatabaseTestIterations = 5; 38 static const int kDatabaseTestIterations = 5;
39 static const int kWebPageReplayIterations = 5;
38 #endif 40 #endif
39 static const int kIDBTestIterations = 5; 41 static const int kIDBTestIterations = 5;
40 42
41 // URL at which data files may be found for HTTP tests. The document root of 43 // URL at which data files may be found for HTTP tests. The document root of
42 // this URL's server should point to data/page_cycler/. 44 // this URL's server should point to data/page_cycler/.
43 static const char kBaseUrl[] = "http://localhost:8000/"; 45 static const char kBaseUrl[] = "http://localhost:8000/";
44 46
45 namespace { 47 namespace {
46 48
47 void PopulateBufferCache(const FilePath& test_dir) { 49 void PopulateBufferCache(const FilePath& test_dir) {
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 } 153 }
152 154
153 virtual bool HasErrors(const std::string /*timings*/) { 155 virtual bool HasErrors(const std::string /*timings*/) {
154 return false; 156 return false;
155 } 157 }
156 158
157 virtual int GetTestIterations() { 159 virtual int GetTestIterations() {
158 return num_test_iterations_; 160 return num_test_iterations_;
159 } 161 }
160 162
161 // For HTTP tests, the name must be safe for use in a URL without escaping. 163 virtual void GetTestUrl(const char* name, bool use_http, GURL *test_url) {
162 void RunPageCycler(const char* name, std::wstring* pages,
163 std::string* timings, bool use_http) {
164 FilePath test_path = GetDataPath(name); 164 FilePath test_path = GetDataPath(name);
165 ASSERT_TRUE(file_util::DirectoryExists(test_path)) 165 ASSERT_TRUE(file_util::DirectoryExists(test_path))
166 << "Missing test directory " << test_path.value(); 166 << "Missing test directory " << test_path.value();
167
168 PopulateBufferCache(test_path); 167 PopulateBufferCache(test_path);
169 168
170 GURL test_url;
171 if (use_http) { 169 if (use_http) {
172 test_url = GURL(std::string(kBaseUrl) + name + "/start.html"); 170 *test_url = GURL(std::string(kBaseUrl) + name + "/start.html");
173 } else { 171 } else {
174 test_path = test_path.Append(FILE_PATH_LITERAL("start.html")); 172 test_path = test_path.Append(FILE_PATH_LITERAL("start.html"));
175 test_url = net::FilePathToFileURL(test_path); 173 *test_url = net::FilePathToFileURL(test_path);
176 } 174 }
177 175
178 // run N iterations 176 // run N iterations
179 GURL::Replacements replacements; 177 GURL::Replacements replacements;
180 const std::string query_string = 178 const std::string query_string =
181 "iterations=" + base::IntToString(GetTestIterations()) + "&auto=1"; 179 "iterations=" + base::IntToString(GetTestIterations()) + "&auto=1";
182 replacements.SetQuery( 180 replacements.SetQuery(
183 query_string.c_str(), 181 query_string.c_str(),
184 url_parse::Component(0, query_string.length())); 182 url_parse::Component(0, query_string.length()));
185 test_url = test_url.ReplaceComponents(replacements); 183 *test_url = test_url->ReplaceComponents(replacements);
184 }
185
186 // For HTTP tests, the name must be safe for use in a URL without escaping.
187 void RunPageCycler(const char* name, std::wstring* pages,
188 std::string* timings, bool use_http) {
189 GURL test_url;
190 GetTestUrl(name, use_http, &test_url);
186 191
187 scoped_refptr<TabProxy> tab(GetActiveTab()); 192 scoped_refptr<TabProxy> tab(GetActiveTab());
188 ASSERT_TRUE(tab.get()); 193 ASSERT_TRUE(tab.get());
189 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, tab->NavigateToURL(test_url)); 194 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, tab->NavigateToURL(test_url));
190 195
191 // Wait for the test to finish. 196 // Wait for the test to finish.
192 ASSERT_TRUE(WaitUntilCookieValue( 197 ASSERT_TRUE(WaitUntilCookieValue(
193 tab.get(), test_url, "__pc_done", 198 tab.get(), test_url, "__pc_done",
194 TestTimeouts::large_test_timeout_ms(), "1")); 199 TestTimeouts::large_test_timeout_ms(), "1"));
195 200
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 441
437 virtual bool HasErrors(const std::string timings) { 442 virtual bool HasErrors(const std::string timings) {
438 return HasDatabaseErrors(timings); 443 return HasDatabaseErrors(timings);
439 } 444 }
440 445
441 virtual int GetTestIterations() { 446 virtual int GetTestIterations() {
442 return kIDBTestIterations; 447 return kIDBTestIterations;
443 } 448 }
444 }; 449 };
445 450
451 // Web Page Replay is a proxy server to record and serve pages
452 // with realistic network delays and bandwidth throttling.
453 // runtest.py launches replay.py to support these tests.
454 class PageCyclerWebPageReplayTest : public PageCyclerTest {
455 public:
456 PageCyclerWebPageReplayTest() {
457 FilePath extension_path = GetPageCyclerWprPath("extension");
458 launch_arguments_.AppendSwitchPath(
459 switches::kLoadExtension, extension_path);
460 launch_arguments_.AppendSwitchASCII(
461 switches::kHostResolverRules, "MAP * 127.0.0.1");
tonyg 2012/04/13 14:32:21 Should add a TODO to remove this (with explanation
slamm_google 2012/04/13 23:43:36 Done.
462 launch_arguments_.AppendSwitchASCII(
463 switches::kTestingFixedHttpPort, "8080");
464 launch_arguments_.AppendSwitchASCII(
465 switches::kTestingFixedHttpsPort, "8413");
466 launch_arguments_.AppendSwitch(switches::kEnableExperimentalExtensionApis);
467 launch_arguments_.AppendSwitch(switches::kEnableStatsTable);
468 launch_arguments_.AppendSwitch(switches::kEnableBenchmarking);
469 launch_arguments_.AppendSwitch(switches::kIgnoreCertificateErrors);
470 launch_arguments_.AppendSwitch(switches::kDisableTranslate);
tonyg 2012/04/13 14:32:21 Necessary? Seems reasonable to model it if it does
slamm_google 2012/04/13 23:43:36 When I ran the test manually, the translate reques
tonyg 2012/04/16 15:34:32 Need to check w/ Chase, but maybe that means it sh
slamm_google 2012/04/16 23:43:07 I removed --disable-translate. It looks like it do
471 launch_arguments_.AppendSwitch(switches::kNoProxyServer);
472 }
473
474 FilePath GetPageCyclerWprPath(const char* name) {
475 FilePath wpr_path;
476 PathService::Get(base::DIR_SOURCE_ROOT, &wpr_path);
477 wpr_path = wpr_path.AppendASCII("tools");
478 wpr_path = wpr_path.AppendASCII("page_cycler");
479 wpr_path = wpr_path.AppendASCII("webpagereplay");
480 wpr_path = wpr_path.AppendASCII(name);
481 return wpr_path;
482 }
483
484 virtual int GetTestIterations() OVERRIDE {
485 return kWebPageReplayIterations;
486 }
487
488 virtual void GetTestUrl(const char* name, bool use_http,
489 GURL *test_url) OVERRIDE {
490 FilePath start_path = GetPageCyclerWprPath("start.html");
491
492 // Add query parameters for iterations and test name.
493 const std::string query_string =
494 "iterations=" + base::IntToString(GetTestIterations()) +
495 "&test=" + name +
496 "&auto=1";
497 GURL::Replacements replacements;
498 replacements.SetQuery(
499 query_string.c_str(),
500 url_parse::Component(0, query_string.length()));
501
502 *test_url = net::FilePathToFileURL(start_path);
503 *test_url = test_url->ReplaceComponents(replacements);
504 }
505
506 void RunTest(const char* graph, const char* name) OVERRIDE {
507 FilePath test_path = GetPageCyclerWprPath("tests");
508 test_path = test_path.AppendASCII(name);
509 test_path = test_path.ReplaceExtension(".js");
510 ASSERT_TRUE(file_util::PathExists(test_path))
511 << "Missing test file " << test_path.value();
512
513 const bool use_http = false; // always use a file
514 PageCyclerTest::RunTestWithSuffix(graph, name, use_http, "");
515 }
516 };
517
446 // This macro simplifies setting up regular and reference build tests. 518 // This macro simplifies setting up regular and reference build tests.
447 #define PAGE_CYCLER_TESTS(test, name, use_http) \ 519 #define PAGE_CYCLER_TESTS(test, name, use_http) \
448 TEST_F(PageCyclerTest, name) { \ 520 TEST_F(PageCyclerTest, name) { \
449 RunTest("times", test, use_http); \ 521 RunTest("times", test, use_http); \
450 } \ 522 } \
451 TEST_F(PageCyclerReferenceTest, name) { \ 523 TEST_F(PageCyclerReferenceTest, name) { \
452 RunTest("times", test, use_http); \ 524 RunTest("times", test, use_http); \
453 } 525 }
454 526
455 // This macro simplifies setting up regular and reference build tests 527 // This macro simplifies setting up regular and reference build tests
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 } 562 }
491 563
492 // This macro lets us define tests with an extension that listens to the 564 // This macro lets us define tests with an extension that listens to the
493 // webrequest.onBeforeRequest. It measures the effect that a blocking event 565 // webrequest.onBeforeRequest. It measures the effect that a blocking event
494 // for every request has on page cycle time. 566 // for every request has on page cycle time.
495 #define PAGE_CYCLER_EXTENSIONS_WEBREQUEST_FILE_TESTS(test, name) \ 567 #define PAGE_CYCLER_EXTENSIONS_WEBREQUEST_FILE_TESTS(test, name) \
496 TEST_F(PageCyclerExtensionWebRequestTest, name) { \ 568 TEST_F(PageCyclerExtensionWebRequestTest, name) { \
497 RunTest("times", "extension_webrequest", "_extwr", test, false); \ 569 RunTest("times", "extension_webrequest", "_extwr", test, false); \
498 } 570 }
499 571
572 #define PAGE_CYCLER_WEBPAGEREPLAY_TESTS(test, name) \
573 TEST_F(PageCyclerWebPageReplayTest, name) { \
574 RunTest("times", test); \
575 }
576
500 // file-URL tests 577 // file-URL tests
501 PAGE_CYCLER_FILE_TESTS("moz", MozFile); 578 PAGE_CYCLER_FILE_TESTS("moz", MozFile);
502 PAGE_CYCLER_EXTENSIONS_FILE_TESTS("moz", MozFile); 579 PAGE_CYCLER_EXTENSIONS_FILE_TESTS("moz", MozFile);
503 PAGE_CYCLER_EXTENSIONS_WEBREQUEST_FILE_TESTS("moz", MozFile) 580 PAGE_CYCLER_EXTENSIONS_WEBREQUEST_FILE_TESTS("moz", MozFile)
504 PAGE_CYCLER_FILE_TESTS("intl1", Intl1File); 581 PAGE_CYCLER_FILE_TESTS("intl1", Intl1File);
505 PAGE_CYCLER_FILE_TESTS("intl2", Intl2File); 582 PAGE_CYCLER_FILE_TESTS("intl2", Intl2File);
506 PAGE_CYCLER_EXTENSIONS_WEBREQUEST_FILE_TESTS("intl2", Intl2File); 583 PAGE_CYCLER_EXTENSIONS_WEBREQUEST_FILE_TESTS("intl2", Intl2File);
507 PAGE_CYCLER_FILE_TESTS("dom", DomFile); 584 PAGE_CYCLER_FILE_TESTS("dom", DomFile);
508 PAGE_CYCLER_FILE_TESTS("dhtml", DhtmlFile); 585 PAGE_CYCLER_FILE_TESTS("dhtml", DhtmlFile);
509 PAGE_CYCLER_FILE_TESTS("morejs", MorejsFile); 586 PAGE_CYCLER_FILE_TESTS("morejs", MorejsFile);
510 PAGE_CYCLER_EXTENSIONS_FILE_TESTS("morejs", MorejsFile); 587 PAGE_CYCLER_EXTENSIONS_FILE_TESTS("morejs", MorejsFile);
511 // added more tests here: 588 // added more tests here:
512 PAGE_CYCLER_FILE_TESTS("alexa_us", Alexa_usFile); 589 PAGE_CYCLER_FILE_TESTS("alexa_us", Alexa_usFile);
513 PAGE_CYCLER_FILE_TESTS("moz2", Moz2File); 590 PAGE_CYCLER_FILE_TESTS("moz2", Moz2File);
514 PAGE_CYCLER_FILE_TESTS("morejsnp", MorejsnpFile); 591 PAGE_CYCLER_FILE_TESTS("morejsnp", MorejsnpFile);
515 PAGE_CYCLER_FILE_TESTS("bloat", BloatFile); 592 PAGE_CYCLER_FILE_TESTS("bloat", BloatFile);
516 593
517 // http (localhost) tests 594 // http (localhost) tests
518 PAGE_CYCLER_HTTP_TESTS("moz", MozHttp); 595 PAGE_CYCLER_HTTP_TESTS("moz", MozHttp);
519 PAGE_CYCLER_HTTP_TESTS("intl1", Intl1Http); 596 PAGE_CYCLER_HTTP_TESTS("intl1", Intl1Http);
520 PAGE_CYCLER_HTTP_TESTS("intl2", Intl2Http); 597 PAGE_CYCLER_HTTP_TESTS("intl2", Intl2Http);
521 PAGE_CYCLER_HTTP_TESTS("dom", DomHttp); 598 PAGE_CYCLER_HTTP_TESTS("dom", DomHttp);
522 PAGE_CYCLER_HTTP_TESTS("bloat", BloatHttp); 599 PAGE_CYCLER_HTTP_TESTS("bloat", BloatHttp);
523 600
601 // Web Page Replay (simulated network) tests.
602 // Windows is unsupported because of issues with loopback adapter and
603 // dummynet is unavailable on Vista and above.
604 #if !defined(OS_WIN)
605 PAGE_CYCLER_WEBPAGEREPLAY_TESTS("2012Q2", 2012Q2);
606 #endif
607
524 // HTML5 database tests 608 // HTML5 database tests
525 // These tests are _really_ slow on XP/Vista. 609 // These tests are _really_ slow on XP/Vista.
526 #if !defined(OS_WIN) 610 #if !defined(OS_WIN)
527 PAGE_CYCLER_DATABASE_TESTS("select-transactions", 611 PAGE_CYCLER_DATABASE_TESTS("select-transactions",
528 SelectTransactions); 612 SelectTransactions);
529 PAGE_CYCLER_DATABASE_TESTS("select-readtransactions", 613 PAGE_CYCLER_DATABASE_TESTS("select-readtransactions",
530 SelectReadTransactions); 614 SelectReadTransactions);
531 PAGE_CYCLER_DATABASE_TESTS("select-readtransactions-read-results", 615 PAGE_CYCLER_DATABASE_TESTS("select-readtransactions-read-results",
532 SelectReadTransactionsReadResults); 616 SelectReadTransactionsReadResults);
533 PAGE_CYCLER_DATABASE_TESTS("insert-transactions", 617 PAGE_CYCLER_DATABASE_TESTS("insert-transactions",
534 InsertTransactions); 618 InsertTransactions);
535 PAGE_CYCLER_DATABASE_TESTS("update-transactions", 619 PAGE_CYCLER_DATABASE_TESTS("update-transactions",
536 UpdateTransactions); 620 UpdateTransactions);
537 PAGE_CYCLER_DATABASE_TESTS("delete-transactions", 621 PAGE_CYCLER_DATABASE_TESTS("delete-transactions",
538 DeleteTransactions); 622 DeleteTransactions);
539 PAGE_CYCLER_DATABASE_TESTS("pseudo-random-transactions", 623 PAGE_CYCLER_DATABASE_TESTS("pseudo-random-transactions",
540 PseudoRandomTransactions); 624 PseudoRandomTransactions);
541 #endif 625 #endif
542 626
543 // Indexed DB tests. 627 // Indexed DB tests.
544 PAGE_CYCLER_IDB_TESTS("basic_insert", BasicInsert); 628 PAGE_CYCLER_IDB_TESTS("basic_insert", BasicInsert);
545 629
546 } // namespace 630 } // namespace
OLDNEW
« no previous file with comments | « no previous file | tools/page_cycler/common/head.js » ('j') | tools/page_cycler/common/report.html » ('J')

Powered by Google App Engine
This is Rietveld 408576698