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