OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include "chrome_frame/test/perf/chrome_frame_perftest.h" | 4 #include "chrome_frame/test/perf/chrome_frame_perftest.h" |
5 | 5 |
6 #include <atlwin.h> | 6 #include <atlwin.h> |
7 #include <atlhost.h> | 7 #include <atlhost.h> |
8 #include <map> | 8 #include <map> |
9 #include <vector> | 9 #include <vector> |
10 #include <string> | 10 #include <string> |
(...skipping 1340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1351 const std::string& trace, | 1351 const std::string& trace, |
1352 const std::string& values, | 1352 const std::string& values, |
1353 const std::string& units, | 1353 const std::string& units, |
1354 bool important) { | 1354 bool important) { |
1355 PrintResultsImpl(measurement, modifier, trace, values, | 1355 PrintResultsImpl(measurement, modifier, trace, values, |
1356 "[", "]", units, important); | 1356 "[", "]", units, important); |
1357 } | 1357 } |
1358 | 1358 |
1359 bool RunSingleTestOutOfProc(const std::string& test_name) { | 1359 bool RunSingleTestOutOfProc(const std::string& test_name) { |
1360 FilePath path; | 1360 FilePath path; |
1361 if (!PathService::Get(base::DIR_EXE, &path)) | 1361 PathService::Get(base::DIR_EXE, &path); |
1362 return false; | |
1363 path = path.Append(L"chrome_frame_tests.exe"); | 1362 path = path.Append(L"chrome_frame_tests.exe"); |
1364 | 1363 |
1365 CommandLine cmd_line(path); | 1364 CommandLine cmd_line(path); |
1366 // Always enable disabled tests. This method is not called with disabled | 1365 // Always enable disabled tests. This method is not called with disabled |
1367 // tests unless this flag was specified to the browser test executable. | 1366 // tests unless this flag was specified to the browser test executable. |
1368 cmd_line.AppendSwitch("gtest_also_run_disabled_tests"); | 1367 cmd_line.AppendSwitch("gtest_also_run_disabled_tests"); |
1369 cmd_line.AppendSwitchASCII("gtest_filter", test_name); | 1368 cmd_line.AppendSwitchASCII("gtest_filter", test_name); |
1370 | 1369 |
1371 base::ProcessHandle process_handle; | 1370 base::ProcessHandle process_handle; |
1372 if (!base::LaunchApp(cmd_line, false, false, &process_handle)) | 1371 if (!base::LaunchApp(cmd_line, false, false, &process_handle)) |
1373 return false; | 1372 return false; |
1374 | 1373 |
1375 int test_terminate_timeout_ms = 60 * 1000; | 1374 int test_terminate_timeout_ms = 60 * 1000; |
1376 int exit_code = 0; | 1375 int exit_code = 0; |
1377 if (!base::WaitForExitCodeWithTimeout(process_handle, &exit_code, | 1376 if (!base::WaitForExitCodeWithTimeout(process_handle, &exit_code, |
1378 test_terminate_timeout_ms)) { | 1377 test_terminate_timeout_ms)) { |
1379 LOG(ERROR) << "Test timeout (" << test_terminate_timeout_ms | 1378 LOG(ERROR) << "Test timeout (" << test_terminate_timeout_ms |
1380 << " ms) exceeded for " << test_name; | 1379 << " ms) exceeded for " << test_name; |
1381 | 1380 |
1382 exit_code = -1; // Set a non-zero exit code to signal a failure. | 1381 exit_code = -1; // Set a non-zero exit code to signal a failure. |
1383 | 1382 |
1384 // Ensure that the process terminates. | 1383 // Ensure that the process terminates. |
1385 base::KillProcess(process_handle, -1, true); | 1384 base::KillProcess(process_handle, -1, true); |
1386 } | 1385 } |
1387 | 1386 |
1388 base::CloseProcessHandle(process_handle); | |
1389 | |
1390 return exit_code == 0; | 1387 return exit_code == 0; |
1391 } | 1388 } |
1392 | 1389 |
1393 template <class Monitor> | 1390 template <class Monitor> |
1394 void PrintPerfTestResults(const Monitor* monitor, | 1391 void PrintPerfTestResults(const Monitor* monitor, |
1395 int num_cycles, | 1392 int num_cycles, |
1396 const char* result_name) { | 1393 const char* result_name) { |
1397 std::string times; | 1394 std::string times; |
1398 | 1395 |
1399 for (int i = 0; i < num_cycles; ++i) { | 1396 for (int i = 0; i < num_cycles; ++i) { |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1473 PrintPerfTestResults(automation_provider_connect_monitor, kNumCycles, | 1470 PrintPerfTestResults(automation_provider_connect_monitor, kNumCycles, |
1474 "automationproviderconnect"); | 1471 "automationproviderconnect"); |
1475 PrintPerfTestResults(external_tab_navigate_monitor, kNumCycles, | 1472 PrintPerfTestResults(external_tab_navigate_monitor, kNumCycles, |
1476 "externaltabnavigate"); | 1473 "externaltabnavigate"); |
1477 PrintPerfTestResults(renderer_main_monitor, kNumCycles, | 1474 PrintPerfTestResults(renderer_main_monitor, kNumCycles, |
1478 "beginrenderermain"); | 1475 "beginrenderermain"); |
1479 #ifdef NDEBUG | 1476 #ifdef NDEBUG |
1480 PrintPerfTestResults(pre_read_chrome_monitor, kNumCycles, "PreReadImage"); | 1477 PrintPerfTestResults(pre_read_chrome_monitor, kNumCycles, "PreReadImage"); |
1481 #endif // NDEBUG | 1478 #endif // NDEBUG |
1482 } | 1479 } |
OLD | NEW |