summaryrefslogtreecommitdiffstats
path: root/chrome/test
diff options
context:
space:
mode:
authorphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-26 18:26:26 +0000
committerphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-26 18:26:26 +0000
commite398a726d2aada2a325f50be21b35374bb57d7bc (patch)
treeb0e83c3e375bdbfd7c932dac9097676a52805a63 /chrome/test
parent6621705e4040c002384afd6e07559b5d53d73b8b (diff)
downloadchromium_src-e398a726d2aada2a325f50be21b35374bb57d7bc.zip
chromium_src-e398a726d2aada2a325f50be21b35374bb57d7bc.tar.gz
chromium_src-e398a726d2aada2a325f50be21b35374bb57d7bc.tar.bz2
GTTF: Extract performance-testing-specific parts of UITestBase to UIPerfTest.
In the future this may even be used to tune some settings/behaviors (like timeouts) for performance tests. TEST=ui_tests, page_cycler_*, etc BUG=none Review URL: http://codereview.chromium.org/3137040 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@57552 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test')
-rw-r--r--chrome/test/memory_test/memory_test.cc4
-rw-r--r--chrome/test/page_cycler/page_cycler_test.cc4
-rw-r--r--chrome/test/startup/feature_startup_test.cc4
-rw-r--r--chrome/test/startup/shutdown_test.cc4
-rw-r--r--chrome/test/startup/startup_test.cc4
-rw-r--r--chrome/test/tab_switching/tab_switching_test.cc4
-rw-r--r--chrome/test/ui/dromaeo_benchmark_uitest.cc4
-rw-r--r--chrome/test/ui/sunspider_uitest.cc4
-rw-r--r--chrome/test/ui/ui_perf_test.cc326
-rw-r--r--chrome/test/ui/ui_perf_test.h91
-rw-r--r--chrome/test/ui/ui_test.cc316
-rw-r--r--chrome/test/ui/ui_test.h74
-rw-r--r--chrome/test/ui/v8_benchmark_uitest.cc4
13 files changed, 435 insertions, 408 deletions
diff --git a/chrome/test/memory_test/memory_test.cc b/chrome/test/memory_test/memory_test.cc
index 249cf16..5024c9c 100644
--- a/chrome/test/memory_test/memory_test.cc
+++ b/chrome/test/memory_test/memory_test.cc
@@ -17,7 +17,7 @@
#include "chrome/test/automation/tab_proxy.h"
#include "chrome/test/automation/window_proxy.h"
#include "chrome/test/chrome_process_util.h"
-#include "chrome/test/ui/ui_test.h"
+#include "chrome/test/ui/ui_perf_test.h"
#include "googleurl/src/gurl.h"
#include "net/base/net_util.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -27,7 +27,7 @@ namespace {
static const FilePath::CharType kTempDirName[] =
FILE_PATH_LITERAL("memory_test_profile");
-class MemoryTest : public UITest {
+class MemoryTest : public UIPerfTest {
public:
MemoryTest() : cleanup_temp_dir_on_exit_(false) {}
diff --git a/chrome/test/page_cycler/page_cycler_test.cc b/chrome/test/page_cycler/page_cycler_test.cc
index d7a7454..5afdbbd 100644
--- a/chrome/test/page_cycler/page_cycler_test.cc
+++ b/chrome/test/page_cycler/page_cycler_test.cc
@@ -19,7 +19,7 @@
#include "chrome/test/automation/window_proxy.h"
#include "chrome/test/chrome_process_util.h"
#include "chrome/test/test_switches.h"
-#include "chrome/test/ui/ui_test.h"
+#include "chrome/test/ui/ui_perf_test.h"
#include "googleurl/src/gurl.h"
#include "net/base/net_util.h"
@@ -151,7 +151,7 @@ void PopulateBufferCache(const FilePath& test_dir) {
LOG(INFO) << "Buffer cache should be primed with " << loaded << " files.";
}
-class PageCyclerTest : public UITest {
+class PageCyclerTest : public UIPerfTest {
protected:
bool print_times_only_;
int num_test_iterations_;
diff --git a/chrome/test/startup/feature_startup_test.cc b/chrome/test/startup/feature_startup_test.cc
index df68386..e89c8d6 100644
--- a/chrome/test/startup/feature_startup_test.cc
+++ b/chrome/test/startup/feature_startup_test.cc
@@ -12,7 +12,7 @@
#include "chrome/common/chrome_switches.h"
#include "chrome/test/automation/browser_proxy.h"
#include "chrome/test/automation/window_proxy.h"
-#include "chrome/test/ui/ui_test.h"
+#include "chrome/test/ui/ui_perf_test.h"
#include "gfx/rect.h"
#include "net/base/net_util.h"
@@ -20,7 +20,7 @@ using base::TimeDelta;
namespace {
-class NewTabUIStartupTest : public UITest {
+class NewTabUIStartupTest : public UIPerfTest {
public:
NewTabUIStartupTest() {
show_window_ = true;
diff --git a/chrome/test/startup/shutdown_test.cc b/chrome/test/startup/shutdown_test.cc
index 9714e04..0d0f609 100644
--- a/chrome/test/startup/shutdown_test.cc
+++ b/chrome/test/startup/shutdown_test.cc
@@ -14,7 +14,7 @@
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/env_vars.h"
-#include "chrome/test/ui/ui_test.h"
+#include "chrome/test/ui/ui_perf_test.h"
#include "chrome/test/ui_test_utils.h"
#include "net/base/net_util.h"
@@ -22,7 +22,7 @@ using base::TimeDelta;
namespace {
-class ShutdownTest : public UITest {
+class ShutdownTest : public UIPerfTest {
public:
ShutdownTest() {
show_window_ = true;
diff --git a/chrome/test/startup/startup_test.cc b/chrome/test/startup/startup_test.cc
index 54c327e..ee8e502 100644
--- a/chrome/test/startup/startup_test.cc
+++ b/chrome/test/startup/startup_test.cc
@@ -16,7 +16,7 @@
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/env_vars.h"
-#include "chrome/test/ui/ui_test.h"
+#include "chrome/test/ui/ui_perf_test.h"
#include "chrome/test/ui_test_utils.h"
#include "net/base/net_util.h"
@@ -25,7 +25,7 @@ using base::TimeTicks;
namespace {
-class StartupTest : public UITest {
+class StartupTest : public UIPerfTest {
public:
StartupTest() {
show_window_ = true;
diff --git a/chrome/test/tab_switching/tab_switching_test.cc b/chrome/test/tab_switching/tab_switching_test.cc
index 1c5b7f2..ba72e7e 100644
--- a/chrome/test/tab_switching/tab_switching_test.cc
+++ b/chrome/test/tab_switching/tab_switching_test.cc
@@ -18,7 +18,7 @@
#include "chrome/common/pref_names.h"
#include "chrome/test/automation/tab_proxy.h"
#include "chrome/test/automation/browser_proxy.h"
-#include "chrome/test/ui/ui_test.h"
+#include "chrome/test/ui/ui_perf_test.h"
#include "googleurl/src/gurl.h"
#include "net/base/net_util.h"
@@ -31,7 +31,7 @@ namespace {
// time taken for each switch. It then prints out the times on the console,
// with the aim that the page cycler parser can interpret these numbers to
// draw graphs for page cycler Tab Switching Performance.
-class TabSwitchingUITest : public UITest {
+class TabSwitchingUITest : public UIPerfTest {
public:
TabSwitchingUITest() {
PathService::Get(base::DIR_SOURCE_ROOT, &path_prefix_);
diff --git a/chrome/test/ui/dromaeo_benchmark_uitest.cc b/chrome/test/ui/dromaeo_benchmark_uitest.cc
index aede3ff..c4736bc 100644
--- a/chrome/test/ui/dromaeo_benchmark_uitest.cc
+++ b/chrome/test/ui/dromaeo_benchmark_uitest.cc
@@ -14,7 +14,7 @@
#include "chrome/common/json_value_serializer.h"
#include "chrome/test/automation/tab_proxy.h"
#include "chrome/test/ui/javascript_test_util.h"
-#include "chrome/test/ui/ui_test.h"
+#include "chrome/test/ui/ui_perf_test.h"
#include "googleurl/src/gurl.h"
#include "net/base/net_util.h"
@@ -22,7 +22,7 @@ namespace {
const char kRunDromaeo[] = "run-dromaeo-benchmark";
-class DromaeoTest : public UITest {
+class DromaeoTest : public UIPerfTest {
public:
typedef std::map<std::string, std::string> ResultsMap;
diff --git a/chrome/test/ui/sunspider_uitest.cc b/chrome/test/ui/sunspider_uitest.cc
index 508f3a3..962d352 100644
--- a/chrome/test/ui/sunspider_uitest.cc
+++ b/chrome/test/ui/sunspider_uitest.cc
@@ -13,7 +13,7 @@
#include "chrome/common/json_value_serializer.h"
#include "chrome/test/automation/tab_proxy.h"
#include "chrome/test/ui/javascript_test_util.h"
-#include "chrome/test/ui/ui_test.h"
+#include "chrome/test/ui/ui_perf_test.h"
#include "googleurl/src/gurl.h"
#include "net/base/net_util.h"
@@ -24,7 +24,7 @@ static const FilePath::CharType kStartFile[] =
const char kRunSunSpider[] = "run-sunspider";
-class SunSpiderTest : public UITest {
+class SunSpiderTest : public UIPerfTest {
public:
typedef std::map<std::string, std::string> ResultsMap;
diff --git a/chrome/test/ui/ui_perf_test.cc b/chrome/test/ui/ui_perf_test.cc
new file mode 100644
index 0000000..c234abf
--- /dev/null
+++ b/chrome/test/ui/ui_perf_test.cc
@@ -0,0 +1,326 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/test/ui/ui_perf_test.h"
+
+#include "base/path_service.h"
+#include "base/string_number_conversions.h"
+#include "chrome/common/chrome_paths.h"
+#include "chrome/test/chrome_process_util.h"
+
+void UIPerfTest::PrintResult(const std::string& measurement,
+ const std::string& modifier,
+ const std::string& trace,
+ size_t value,
+ const std::string& units,
+ bool important) {
+ PrintResultsImpl(measurement, modifier, trace, base::UintToString(value),
+ "", "", units, important);
+}
+
+void UIPerfTest::PrintResult(const std::string& measurement,
+ const std::string& modifier,
+ const std::string& trace,
+ const std::string& value,
+ const std::string& units,
+ bool important) {
+ PrintResultsImpl(measurement, modifier, trace, value, "", "", units,
+ important);
+}
+
+void UIPerfTest::PrintResultMeanAndError(const std::string& measurement,
+ const std::string& modifier,
+ const std::string& trace,
+ const std::string& mean_and_error,
+ const std::string& units,
+ bool important) {
+ PrintResultsImpl(measurement, modifier, trace, mean_and_error,
+ "{", "}", units, important);
+}
+
+void UIPerfTest::PrintResultList(const std::string& measurement,
+ const std::string& modifier,
+ const std::string& trace,
+ const std::string& values,
+ const std::string& units,
+ bool important) {
+ PrintResultsImpl(measurement, modifier, trace, values,
+ "[", "]", units, important);
+}
+
+void UIPerfTest::PrintResultsImpl(const std::string& measurement,
+ const std::string& modifier,
+ const std::string& trace,
+ const std::string& values,
+ const std::string& prefix,
+ const std::string& suffix,
+ const std::string& units,
+ bool important) {
+ // <*>RESULT <graph_name>: <trace_name>= <value> <units>
+ // <*>RESULT <graph_name>: <trace_name>= {<mean>, <std deviation>} <units>
+ // <*>RESULT <graph_name>: <trace_name>= [<value>,value,value,...,] <units>
+ printf("%sRESULT %s%s: %s= %s%s%s %s\n",
+ important ? "*" : "", measurement.c_str(), modifier.c_str(),
+ trace.c_str(), prefix.c_str(), values.c_str(), suffix.c_str(),
+ units.c_str());
+}
+
+void UIPerfTest::PrintIOPerfInfo(const char* test_name) {
+ ChromeProcessList chrome_processes(GetRunningChromeProcesses(process_id_));
+
+ size_t read_op_b = 0;
+ size_t read_op_r = 0;
+ size_t write_op_b = 0;
+ size_t write_op_r = 0;
+ size_t other_op_b = 0;
+ size_t other_op_r = 0;
+ size_t total_op_b = 0;
+ size_t total_op_r = 0;
+
+ size_t read_byte_b = 0;
+ size_t read_byte_r = 0;
+ size_t write_byte_b = 0;
+ size_t write_byte_r = 0;
+ size_t other_byte_b = 0;
+ size_t other_byte_r = 0;
+ size_t total_byte_b = 0;
+ size_t total_byte_r = 0;
+
+ ChromeProcessList::const_iterator it;
+ for (it = chrome_processes.begin(); it != chrome_processes.end(); ++it) {
+ base::ProcessHandle process_handle;
+ if (!base::OpenPrivilegedProcessHandle(*it, &process_handle)) {
+ NOTREACHED();
+ return;
+ }
+
+ // TODO(sgk): if/when base::ProcessMetrics returns real stats on mac:
+ // scoped_ptr<base::ProcessMetrics> process_metrics(
+ // base::ProcessMetrics::CreateProcessMetrics(process_handle));
+ scoped_ptr<ChromeTestProcessMetrics> process_metrics(
+ ChromeTestProcessMetrics::CreateProcessMetrics(process_handle));
+ base::IoCounters io_counters;
+ memset(&io_counters, 0, sizeof(io_counters));
+
+ if (process_metrics.get()->GetIOCounters(&io_counters)) {
+ // Print out IO performance. We assume that the values can be
+ // converted to size_t (they're reported as ULONGLONG, 64-bit numbers).
+ std::string chrome_name = (*it == browser_process_id()) ? "_b" : "_r";
+
+ size_t read_op = static_cast<size_t>(io_counters.ReadOperationCount);
+ size_t write_op = static_cast<size_t>(io_counters.WriteOperationCount);
+ size_t other_op = static_cast<size_t>(io_counters.OtherOperationCount);
+ size_t total_op = static_cast<size_t>(io_counters.ReadOperationCount +
+ io_counters.WriteOperationCount +
+ io_counters.OtherOperationCount);
+
+ size_t read_byte = static_cast<size_t>(io_counters.ReadTransferCount
+ / 1024);
+ size_t write_byte = static_cast<size_t>(io_counters.WriteTransferCount
+ / 1024);
+ size_t other_byte = static_cast<size_t>(io_counters.OtherTransferCount
+ / 1024);
+ size_t total_byte = static_cast<size_t>((io_counters.ReadTransferCount +
+ io_counters.WriteTransferCount +
+ io_counters.OtherTransferCount)
+ / 1024);
+
+ if (*it == browser_process_id()) {
+ read_op_b = read_op;
+ write_op_b = write_op;
+ other_op_b = other_op;
+ total_op_b = total_op;
+ read_byte_b = read_byte;
+ write_byte_b = write_byte;
+ other_byte_b = other_byte;
+ total_byte_b = total_byte;
+ } else {
+ read_op_r += read_op;
+ write_op_r += write_op;
+ other_op_r += other_op;
+ total_op_r += total_op;
+ read_byte_r += read_byte;
+ write_byte_r += write_byte;
+ other_byte_r += other_byte;
+ total_byte_r += total_byte;
+ }
+ }
+
+ base::CloseProcessHandle(process_handle);
+ }
+
+ std::string t_name(test_name);
+ PrintResult("read_op_b", "", "r_op_b" + t_name, read_op_b, "", false);
+ PrintResult("write_op_b", "", "w_op_b" + t_name, write_op_b, "", false);
+ PrintResult("other_op_b", "", "o_op_b" + t_name, other_op_b, "", false);
+ PrintResult("total_op_b", "", "IO_op_b" + t_name, total_op_b, "", true);
+
+ PrintResult("read_byte_b", "", "r_b" + t_name, read_byte_b, "kb", false);
+ PrintResult("write_byte_b", "", "w_b" + t_name, write_byte_b, "kb", false);
+ PrintResult("other_byte_b", "", "o_b" + t_name, other_byte_b, "kb", false);
+ PrintResult("total_byte_b", "", "IO_b" + t_name, total_byte_b, "kb", true);
+
+ PrintResult("read_op_r", "", "r_op_r" + t_name, read_op_r, "", false);
+ PrintResult("write_op_r", "", "w_op_r" + t_name, write_op_r, "", false);
+ PrintResult("other_op_r", "", "o_op_r" + t_name, other_op_r, "", false);
+ PrintResult("total_op_r", "", "IO_op_r" + t_name, total_op_r, "", true);
+
+ PrintResult("read_byte_r", "", "r_r" + t_name, read_byte_r, "kb", false);
+ PrintResult("write_byte_r", "", "w_r" + t_name, write_byte_r, "kb", false);
+ PrintResult("other_byte_r", "", "o_r" + t_name, other_byte_r, "kb", false);
+ PrintResult("total_byte_r", "", "IO_r" + t_name, total_byte_r, "kb", true);
+}
+
+void UIPerfTest::PrintMemoryUsageInfo(const char* test_name) {
+ ChromeProcessList chrome_processes(GetRunningChromeProcesses(process_id_));
+
+ size_t browser_virtual_size = 0;
+ size_t browser_working_set_size = 0;
+ size_t renderer_virtual_size = 0;
+ size_t renderer_working_set_size = 0;
+ size_t total_virtual_size = 0;
+ size_t total_working_set_size = 0;
+#if defined(OS_WIN)
+ size_t browser_peak_virtual_size = 0;
+ size_t browser_peak_working_set_size = 0;
+ size_t renderer_total_peak_virtual_size = 0;
+ size_t renderer_total_peak_working_set_size = 0;
+ size_t renderer_single_peak_virtual_size = 0;
+ size_t renderer_single_peak_working_set_size = 0;
+#endif
+
+ ChromeProcessList::const_iterator it;
+ for (it = chrome_processes.begin(); it != chrome_processes.end(); ++it) {
+ base::ProcessHandle process_handle;
+ if (!base::OpenPrivilegedProcessHandle(*it, &process_handle)) {
+ NOTREACHED();
+ return;
+ }
+
+ // TODO(sgk): if/when base::ProcessMetrics returns real stats on mac:
+ // scoped_ptr<base::ProcessMetrics> process_metrics(
+ // base::ProcessMetrics::CreateProcessMetrics(process_handle));
+ scoped_ptr<ChromeTestProcessMetrics> process_metrics(
+ ChromeTestProcessMetrics::CreateProcessMetrics(process_handle));
+
+ size_t current_virtual_size = process_metrics->GetPagefileUsage();
+ size_t current_working_set_size = process_metrics->GetWorkingSetSize();
+
+ if (*it == browser_process_id()) {
+ browser_virtual_size = current_virtual_size;
+ browser_working_set_size = current_working_set_size;
+ } else {
+ renderer_virtual_size += current_virtual_size;
+ renderer_working_set_size += current_working_set_size;
+ }
+ total_virtual_size += current_virtual_size;
+ total_working_set_size += current_working_set_size;
+
+#if defined(OS_WIN)
+ size_t peak_virtual_size = process_metrics->GetPeakPagefileUsage();
+ size_t peak_working_set_size = process_metrics->GetPeakWorkingSetSize();
+ if (*it == browser_process_id()) {
+ browser_peak_virtual_size = peak_virtual_size;
+ browser_peak_working_set_size = peak_working_set_size;
+ } else {
+ if (peak_virtual_size > renderer_single_peak_virtual_size) {
+ renderer_single_peak_virtual_size = peak_virtual_size;
+ }
+ if (peak_working_set_size > renderer_single_peak_working_set_size) {
+ renderer_single_peak_working_set_size = peak_working_set_size;
+ }
+ renderer_total_peak_virtual_size += peak_virtual_size;
+ renderer_total_peak_working_set_size += peak_working_set_size;
+ }
+#endif
+
+ base::CloseProcessHandle(process_handle);
+ }
+
+ std::string trace_name(test_name);
+#if defined(OS_WIN)
+ PrintResult("vm_peak_b", "", "vm_pk_b" + trace_name,
+ browser_peak_virtual_size, "bytes",
+ true /* important */);
+ PrintResult("ws_peak_b", "", "ws_pk_b" + trace_name,
+ browser_peak_working_set_size, "bytes",
+ true /* important */);
+ PrintResult("vm_peak_r", "", "vm_pk_r" + trace_name,
+ renderer_total_peak_virtual_size, "bytes",
+ true /* important */);
+ PrintResult("ws_peak_r", "", "ws_pk_r" + trace_name,
+ renderer_total_peak_working_set_size, "bytes",
+ true /* important */);
+ PrintResult("vm_single_peak_r", "", "vm_spk_r" + trace_name,
+ renderer_single_peak_virtual_size, "bytes",
+ true /* important */);
+ PrintResult("ws_single_peak_r", "", "ws_spk_r" + trace_name,
+ renderer_single_peak_working_set_size, "bytes",
+ true /* important */);
+
+ PrintResult("vm_final_b", "", "vm_f_b" + trace_name,
+ browser_virtual_size, "bytes",
+ false /* not important */);
+ PrintResult("ws_final_b", "", "ws_f_b" + trace_name,
+ browser_working_set_size, "bytes",
+ false /* not important */);
+ PrintResult("vm_final_r", "", "vm_f_r" + trace_name,
+ renderer_virtual_size, "bytes",
+ false /* not important */);
+ PrintResult("ws_final_r", "", "ws_f_r" + trace_name,
+ renderer_working_set_size, "bytes",
+ false /* not important */);
+ PrintResult("vm_final_t", "", "vm_f_t" + trace_name,
+ total_virtual_size, "bytes",
+ false /* not important */);
+ PrintResult("ws_final_t", "", "ws_f_t" + trace_name,
+ total_working_set_size, "bytes",
+ false /* not important */);
+#elif defined(OS_LINUX) || defined(OS_MACOSX)
+ PrintResult("vm_size_final_b", "", "vm_size_f_b" + trace_name,
+ browser_virtual_size, "bytes",
+ true /* important */);
+ PrintResult("vm_rss_final_b", "", "vm_rss_f_b" + trace_name,
+ browser_working_set_size, "bytes",
+ true /* important */);
+ PrintResult("vm_size_final_r", "", "vm_size_f_r" + trace_name,
+ renderer_virtual_size, "bytes",
+ true /* important */);
+ PrintResult("vm_rss_final_r", "", "vm_rss_f_r" + trace_name,
+ renderer_working_set_size, "bytes",
+ true /* important */);
+ PrintResult("vm_size_final_t", "", "vm_size_f_t" + trace_name,
+ total_virtual_size, "bytes",
+ true /* important */);
+ PrintResult("vm_rss_final_t", "", "vm_rss_f_t" + trace_name,
+ total_working_set_size, "bytes",
+ true /* important */);
+#else
+ NOTIMPLEMENTED();
+#endif
+ PrintResult("processes", "", "proc_" + trace_name,
+ chrome_processes.size(), "",
+ false /* not important */);
+}
+
+void UIPerfTest::PrintSystemCommitCharge(const char* test_name,
+ size_t charge,
+ bool important) {
+ std::string trace_name(test_name);
+ PrintResult("commit_charge", "", "cc" + trace_name, charge, "kb", important);
+}
+
+void UIPerfTest::UseReferenceBuild() {
+ FilePath dir;
+ PathService::Get(chrome::DIR_TEST_TOOLS, &dir);
+ dir = dir.AppendASCII("reference_build");
+#if defined(OS_WIN)
+ dir = dir.AppendASCII("chrome");
+#elif defined(OS_LINUX)
+ dir = dir.AppendASCII("chrome_linux");
+#elif defined(OS_MACOSX)
+ dir = dir.AppendASCII("chrome_mac");
+#endif
+ SetBrowserDirectory(dir);
+}
diff --git a/chrome/test/ui/ui_perf_test.h b/chrome/test/ui/ui_perf_test.h
new file mode 100644
index 0000000..08daca8
--- /dev/null
+++ b/chrome/test/ui/ui_perf_test.h
@@ -0,0 +1,91 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_TEST_UI_UI_PERF_TEST_H_
+#define CHROME_TEST_UI_UI_PERF_TEST_H_
+#pragma once
+
+#include <string>
+
+#include "chrome/test/ui/ui_test.h"
+
+class UIPerfTest : public UITest {
+ protected:
+ // Prints numerical information to stdout in a controlled format, for
+ // post-processing. |measurement| is a description of the quantity being
+ // measured, e.g. "vm_peak"; |modifier| is provided as a convenience and
+ // will be appended directly to the name of the |measurement|, e.g.
+ // "_browser"; |trace| is a description of the particular data point, e.g.
+ // "reference"; |value| is the measured value; and |units| is a description
+ // of the units of measure, e.g. "bytes". If |important| is true, the output
+ // line will be specially marked, to notify the post-processor. The strings
+ // may be empty. They should not contain any colons (:) or equals signs (=).
+ // A typical post-processing step would be to produce graphs of the data
+ // produced for various builds, using the combined |measurement| + |modifier|
+ // string to specify a particular graph and the |trace| to identify a trace
+ // (i.e., data series) on that graph.
+ void PrintResult(const std::string& measurement,
+ const std::string& modifier,
+ const std::string& trace,
+ size_t value,
+ const std::string& units,
+ bool important);
+
+ // Like the above version of PrintResult(), but takes a std::string value
+ // instead of a size_t.
+ void PrintResult(const std::string& measurement,
+ const std::string& modifier,
+ const std::string& trace,
+ const std::string& value,
+ const std::string& units,
+ bool important);
+
+ // Like PrintResult(), but prints a (mean, standard deviation) result pair.
+ // The |<values>| should be two comma-seaprated numbers, the mean and
+ // standard deviation (or other error metric) of the measurement.
+ void PrintResultMeanAndError(const std::string& measurement,
+ const std::string& modifier,
+ const std::string& trace,
+ const std::string& mean_and_error,
+ const std::string& units,
+ bool important);
+
+ // Like PrintResult(), but prints an entire list of results. The |values|
+ // will generally be a list of comma-separated numbers. A typical
+ // post-processing step might produce plots of their mean and standard
+ // deviation.
+ void PrintResultList(const std::string& measurement,
+ const std::string& modifier,
+ const std::string& trace,
+ const std::string& values,
+ const std::string& units,
+ bool important);
+
+ // Prints IO performance data for use by perf graphs.
+ void PrintIOPerfInfo(const char* test_name);
+
+ // Prints memory usage data for use by perf graphs.
+ void PrintMemoryUsageInfo(const char* test_name);
+
+ // Prints memory commit charge stats for use by perf graphs.
+ void PrintSystemCommitCharge(const char* test_name,
+ size_t charge,
+ bool important);
+
+ // Configures the test to use the reference build.
+ void UseReferenceBuild();
+
+ private:
+ // Common functionality for the public PrintResults methods.
+ void PrintResultsImpl(const std::string& measurement,
+ const std::string& modifier,
+ const std::string& trace,
+ const std::string& values,
+ const std::string& prefix,
+ const std::string& suffix,
+ const std::string& units,
+ bool important);
+};
+
+#endif // CHROME_TEST_UI_UI_PERF_TEST_H_
diff --git a/chrome/test/ui/ui_test.cc b/chrome/test/ui/ui_test.cc
index b321ebf..9b4f645 100644
--- a/chrome/test/ui/ui_test.cc
+++ b/chrome/test/ui/ui_test.cc
@@ -931,63 +931,6 @@ void UITestBase::WaitForFinish(const std::string &name,
EXPECT_EQ(expected_cookie_value, cookie_value);
}
-void UITestBase::PrintResult(const std::string& measurement,
- const std::string& modifier,
- const std::string& trace,
- size_t value,
- const std::string& units,
- bool important) {
- PrintResultsImpl(measurement, modifier, trace, base::UintToString(value),
- "", "", units, important);
-}
-
-void UITestBase::PrintResult(const std::string& measurement,
- const std::string& modifier,
- const std::string& trace,
- const std::string& value,
- const std::string& units,
- bool important) {
- PrintResultsImpl(measurement, modifier, trace, value, "", "", units,
- important);
-}
-
-void UITestBase::PrintResultMeanAndError(const std::string& measurement,
- const std::string& modifier,
- const std::string& trace,
- const std::string& mean_and_error,
- const std::string& units,
- bool important) {
- PrintResultsImpl(measurement, modifier, trace, mean_and_error,
- "{", "}", units, important);
-}
-
-void UITestBase::PrintResultList(const std::string& measurement,
- const std::string& modifier,
- const std::string& trace,
- const std::string& values,
- const std::string& units,
- bool important) {
- PrintResultsImpl(measurement, modifier, trace, values,
- "[", "]", units, important);
-}
-
-void UITestBase::PrintResultsImpl(const std::string& measurement,
- const std::string& modifier,
- const std::string& trace,
- const std::string& values,
- const std::string& prefix,
- const std::string& suffix,
- const std::string& units,
- bool important) {
- // <*>RESULT <graph_name>: <trace_name>= <value> <units>
- // <*>RESULT <graph_name>: <trace_name>= {<mean>, <std deviation>} <units>
- // <*>RESULT <graph_name>: <trace_name>= [<value>,value,value,...,] <units>
- printf("%sRESULT %s%s: %s= %s%s%s %s\n",
- important ? "*" : "", measurement.c_str(), modifier.c_str(),
- trace.c_str(), prefix.c_str(), values.c_str(), suffix.c_str(),
- units.c_str());
-}
-
bool UITestBase::EvictFileFromSystemCacheWrapper(const FilePath& path) {
for (int i = 0; i < 10; i++) {
if (file_util::EvictFileFromSystemCache(path))
@@ -1257,265 +1200,6 @@ void UITestBase::UpdateHistoryDates() {
file_util::EvictFileFromSystemCache(history);
}
-void UITestBase::PrintIOPerfInfo(const char* test_name) {
- ChromeProcessList chrome_processes(GetRunningChromeProcesses(process_id_));
-
- size_t read_op_b = 0;
- size_t read_op_r = 0;
- size_t write_op_b = 0;
- size_t write_op_r = 0;
- size_t other_op_b = 0;
- size_t other_op_r = 0;
- size_t total_op_b = 0;
- size_t total_op_r = 0;
-
- size_t read_byte_b = 0;
- size_t read_byte_r = 0;
- size_t write_byte_b = 0;
- size_t write_byte_r = 0;
- size_t other_byte_b = 0;
- size_t other_byte_r = 0;
- size_t total_byte_b = 0;
- size_t total_byte_r = 0;
-
- ChromeProcessList::const_iterator it;
- for (it = chrome_processes.begin(); it != chrome_processes.end(); ++it) {
- base::ProcessHandle process_handle;
- if (!base::OpenPrivilegedProcessHandle(*it, &process_handle)) {
- NOTREACHED();
- return;
- }
-
- // TODO(sgk): if/when base::ProcessMetrics returns real stats on mac:
- // scoped_ptr<base::ProcessMetrics> process_metrics(
- // base::ProcessMetrics::CreateProcessMetrics(process_handle));
- scoped_ptr<ChromeTestProcessMetrics> process_metrics(
- ChromeTestProcessMetrics::CreateProcessMetrics(process_handle));
- base::IoCounters io_counters;
- memset(&io_counters, 0, sizeof(io_counters));
-
- if (process_metrics.get()->GetIOCounters(&io_counters)) {
- // Print out IO performance. We assume that the values can be
- // converted to size_t (they're reported as ULONGLONG, 64-bit numbers).
- std::string chrome_name = (*it == browser_process_id()) ? "_b" : "_r";
-
- size_t read_op = static_cast<size_t>(io_counters.ReadOperationCount);
- size_t write_op = static_cast<size_t>(io_counters.WriteOperationCount);
- size_t other_op = static_cast<size_t>(io_counters.OtherOperationCount);
- size_t total_op = static_cast<size_t>(io_counters.ReadOperationCount +
- io_counters.WriteOperationCount +
- io_counters.OtherOperationCount);
-
- size_t read_byte = static_cast<size_t>(io_counters.ReadTransferCount
- / 1024);
- size_t write_byte = static_cast<size_t>(io_counters.WriteTransferCount
- / 1024);
- size_t other_byte = static_cast<size_t>(io_counters.OtherTransferCount
- / 1024);
- size_t total_byte = static_cast<size_t>((io_counters.ReadTransferCount +
- io_counters.WriteTransferCount +
- io_counters.OtherTransferCount)
- / 1024);
-
- if (*it == browser_process_id()) {
- read_op_b = read_op;
- write_op_b = write_op;
- other_op_b = other_op;
- total_op_b = total_op;
- read_byte_b = read_byte;
- write_byte_b = write_byte;
- other_byte_b = other_byte;
- total_byte_b = total_byte;
- } else {
- read_op_r += read_op;
- write_op_r += write_op;
- other_op_r += other_op;
- total_op_r += total_op;
- read_byte_r += read_byte;
- write_byte_r += write_byte;
- other_byte_r += other_byte;
- total_byte_r += total_byte;
- }
- }
-
- base::CloseProcessHandle(process_handle);
- }
-
- std::string t_name(test_name);
- PrintResult("read_op_b", "", "r_op_b" + t_name, read_op_b, "", false);
- PrintResult("write_op_b", "", "w_op_b" + t_name, write_op_b, "", false);
- PrintResult("other_op_b", "", "o_op_b" + t_name, other_op_b, "", false);
- PrintResult("total_op_b", "", "IO_op_b" + t_name, total_op_b, "", true);
-
- PrintResult("read_byte_b", "", "r_b" + t_name, read_byte_b, "kb", false);
- PrintResult("write_byte_b", "", "w_b" + t_name, write_byte_b, "kb", false);
- PrintResult("other_byte_b", "", "o_b" + t_name, other_byte_b, "kb", false);
- PrintResult("total_byte_b", "", "IO_b" + t_name, total_byte_b, "kb", true);
-
- PrintResult("read_op_r", "", "r_op_r" + t_name, read_op_r, "", false);
- PrintResult("write_op_r", "", "w_op_r" + t_name, write_op_r, "", false);
- PrintResult("other_op_r", "", "o_op_r" + t_name, other_op_r, "", false);
- PrintResult("total_op_r", "", "IO_op_r" + t_name, total_op_r, "", true);
-
- PrintResult("read_byte_r", "", "r_r" + t_name, read_byte_r, "kb", false);
- PrintResult("write_byte_r", "", "w_r" + t_name, write_byte_r, "kb", false);
- PrintResult("other_byte_r", "", "o_r" + t_name, other_byte_r, "kb", false);
- PrintResult("total_byte_r", "", "IO_r" + t_name, total_byte_r, "kb", true);
-}
-
-void UITestBase::PrintMemoryUsageInfo(const char* test_name) {
- ChromeProcessList chrome_processes(GetRunningChromeProcesses(process_id_));
-
- size_t browser_virtual_size = 0;
- size_t browser_working_set_size = 0;
- size_t renderer_virtual_size = 0;
- size_t renderer_working_set_size = 0;
- size_t total_virtual_size = 0;
- size_t total_working_set_size = 0;
-#if defined(OS_WIN)
- size_t browser_peak_virtual_size = 0;
- size_t browser_peak_working_set_size = 0;
- size_t renderer_total_peak_virtual_size = 0;
- size_t renderer_total_peak_working_set_size = 0;
- size_t renderer_single_peak_virtual_size = 0;
- size_t renderer_single_peak_working_set_size = 0;
-#endif
-
- ChromeProcessList::const_iterator it;
- for (it = chrome_processes.begin(); it != chrome_processes.end(); ++it) {
- base::ProcessHandle process_handle;
- if (!base::OpenPrivilegedProcessHandle(*it, &process_handle)) {
- NOTREACHED();
- return;
- }
-
- // TODO(sgk): if/when base::ProcessMetrics returns real stats on mac:
- // scoped_ptr<base::ProcessMetrics> process_metrics(
- // base::ProcessMetrics::CreateProcessMetrics(process_handle));
- scoped_ptr<ChromeTestProcessMetrics> process_metrics(
- ChromeTestProcessMetrics::CreateProcessMetrics(process_handle));
-
- size_t current_virtual_size = process_metrics->GetPagefileUsage();
- size_t current_working_set_size = process_metrics->GetWorkingSetSize();
-
- if (*it == browser_process_id()) {
- browser_virtual_size = current_virtual_size;
- browser_working_set_size = current_working_set_size;
- } else {
- renderer_virtual_size += current_virtual_size;
- renderer_working_set_size += current_working_set_size;
- }
- total_virtual_size += current_virtual_size;
- total_working_set_size += current_working_set_size;
-
-#if defined(OS_WIN)
- size_t peak_virtual_size = process_metrics->GetPeakPagefileUsage();
- size_t peak_working_set_size = process_metrics->GetPeakWorkingSetSize();
- if (*it == browser_process_id()) {
- browser_peak_virtual_size = peak_virtual_size;
- browser_peak_working_set_size = peak_working_set_size;
- } else {
- if (peak_virtual_size > renderer_single_peak_virtual_size) {
- renderer_single_peak_virtual_size = peak_virtual_size;
- }
- if (peak_working_set_size > renderer_single_peak_working_set_size) {
- renderer_single_peak_working_set_size = peak_working_set_size;
- }
- renderer_total_peak_virtual_size += peak_virtual_size;
- renderer_total_peak_working_set_size += peak_working_set_size;
- }
-#endif
-
- base::CloseProcessHandle(process_handle);
- }
-
- std::string trace_name(test_name);
-#if defined(OS_WIN)
- PrintResult("vm_peak_b", "", "vm_pk_b" + trace_name,
- browser_peak_virtual_size, "bytes",
- true /* important */);
- PrintResult("ws_peak_b", "", "ws_pk_b" + trace_name,
- browser_peak_working_set_size, "bytes",
- true /* important */);
- PrintResult("vm_peak_r", "", "vm_pk_r" + trace_name,
- renderer_total_peak_virtual_size, "bytes",
- true /* important */);
- PrintResult("ws_peak_r", "", "ws_pk_r" + trace_name,
- renderer_total_peak_working_set_size, "bytes",
- true /* important */);
- PrintResult("vm_single_peak_r", "", "vm_spk_r" + trace_name,
- renderer_single_peak_virtual_size, "bytes",
- true /* important */);
- PrintResult("ws_single_peak_r", "", "ws_spk_r" + trace_name,
- renderer_single_peak_working_set_size, "bytes",
- true /* important */);
-
- PrintResult("vm_final_b", "", "vm_f_b" + trace_name,
- browser_virtual_size, "bytes",
- false /* not important */);
- PrintResult("ws_final_b", "", "ws_f_b" + trace_name,
- browser_working_set_size, "bytes",
- false /* not important */);
- PrintResult("vm_final_r", "", "vm_f_r" + trace_name,
- renderer_virtual_size, "bytes",
- false /* not important */);
- PrintResult("ws_final_r", "", "ws_f_r" + trace_name,
- renderer_working_set_size, "bytes",
- false /* not important */);
- PrintResult("vm_final_t", "", "vm_f_t" + trace_name,
- total_virtual_size, "bytes",
- false /* not important */);
- PrintResult("ws_final_t", "", "ws_f_t" + trace_name,
- total_working_set_size, "bytes",
- false /* not important */);
-#elif defined(OS_LINUX) || defined(OS_MACOSX)
- PrintResult("vm_size_final_b", "", "vm_size_f_b" + trace_name,
- browser_virtual_size, "bytes",
- true /* important */);
- PrintResult("vm_rss_final_b", "", "vm_rss_f_b" + trace_name,
- browser_working_set_size, "bytes",
- true /* important */);
- PrintResult("vm_size_final_r", "", "vm_size_f_r" + trace_name,
- renderer_virtual_size, "bytes",
- true /* important */);
- PrintResult("vm_rss_final_r", "", "vm_rss_f_r" + trace_name,
- renderer_working_set_size, "bytes",
- true /* important */);
- PrintResult("vm_size_final_t", "", "vm_size_f_t" + trace_name,
- total_virtual_size, "bytes",
- true /* important */);
- PrintResult("vm_rss_final_t", "", "vm_rss_f_t" + trace_name,
- total_working_set_size, "bytes",
- true /* important */);
-#else
- NOTIMPLEMENTED();
-#endif
- PrintResult("processes", "", "proc_" + trace_name,
- chrome_processes.size(), "",
- false /* not important */);
-}
-
-void UITestBase::PrintSystemCommitCharge(const char* test_name,
- size_t charge,
- bool important) {
- std::string trace_name(test_name);
- PrintResult("commit_charge", "", "cc" + trace_name, charge, "kb", important);
-}
-
-void UITestBase::UseReferenceBuild() {
- FilePath dir;
- PathService::Get(chrome::DIR_TEST_TOOLS, &dir);
- dir = dir.AppendASCII("reference_build");
-#if defined(OS_WIN)
- dir = dir.AppendASCII("chrome");
-#elif defined(OS_LINUX)
- dir = dir.AppendASCII("chrome_linux");
-#elif defined(OS_MACOSX)
- dir = dir.AppendASCII("chrome_mac");
-#endif
- SetBrowserDirectory(dir);
-}
-
void UITestBase::SetBrowserDirectory(const FilePath& dir) {
browser_directory_ = dir;
}
diff --git a/chrome/test/ui/ui_test.h b/chrome/test/ui/ui_test.h
index f10df9b..4b9a5b1 100644
--- a/chrome/test/ui/ui_test.h
+++ b/chrome/test/ui/ui_test.h
@@ -234,56 +234,6 @@ class UITestBase {
// after the browser process has terminated.
bool CloseBrowser(BrowserProxy* browser, bool* application_closed) const;
- // Prints numerical information to stdout in a controlled format, for
- // post-processing. |measurement| is a description of the quantity being
- // measured, e.g. "vm_peak"; |modifier| is provided as a convenience and
- // will be appended directly to the name of the |measurement|, e.g.
- // "_browser"; |trace| is a description of the particular data point, e.g.
- // "reference"; |value| is the measured value; and |units| is a description
- // of the units of measure, e.g. "bytes". If |important| is true, the output
- // line will be specially marked, to notify the post-processor. The strings
- // may be empty. They should not contain any colons (:) or equals signs (=).
- // A typical post-processing step would be to produce graphs of the data
- // produced for various builds, using the combined |measurement| + |modifier|
- // string to specify a particular graph and the |trace| to identify a trace
- // (i.e., data series) on that graph.
- void PrintResult(const std::string& measurement,
- const std::string& modifier,
- const std::string& trace,
- size_t value,
- const std::string& units,
- bool important);
-
- // Like the above version of PrintResult(), but takes a std::string value
- // instead of a size_t.
- void PrintResult(const std::string& measurement,
- const std::string& modifier,
- const std::string& trace,
- const std::string& value,
- const std::string& units,
- bool important);
-
- // Like PrintResult(), but prints a (mean, standard deviation) result pair.
- // The |<values>| should be two comma-seaprated numbers, the mean and
- // standard deviation (or other error metric) of the measurement.
- void PrintResultMeanAndError(const std::string& measurement,
- const std::string& modifier,
- const std::string& trace,
- const std::string& mean_and_error,
- const std::string& units,
- bool important);
-
- // Like PrintResult(), but prints an entire list of results. The |values|
- // will generally be a list of comma-separated numbers. A typical
- // post-processing step might produce plots of their mean and standard
- // deviation.
- void PrintResultList(const std::string& measurement,
- const std::string& modifier,
- const std::string& trace,
- const std::string& values,
- const std::string& units,
- bool important);
-
// Gets the directory for the currently active profile in the browser.
FilePath GetDownloadDirectory();
@@ -491,20 +441,6 @@ class UITestBase {
void StopHttpServer();
- // Prints IO performance data for use by perf graphs.
- void PrintIOPerfInfo(const char* test_name);
-
- // Prints memory usage data for use by perf graphs.
- void PrintMemoryUsageInfo(const char* test_name);
-
- // Prints memory commit charge stats for use by perf graphs.
- void PrintSystemCommitCharge(const char* test_name,
- size_t charge,
- bool important);
-
- // Configures the test to use the reference build.
- void UseReferenceBuild();
-
// Use Chromium binaries from the given directory.
void SetBrowserDirectory(const FilePath& dir);
@@ -513,16 +449,6 @@ class UITestBase {
// the given message if any do.
void AssertAppNotRunning(const std::wstring& error_message);
- // Common functionality for the public PrintResults methods.
- void PrintResultsImpl(const std::string& measurement,
- const std::string& modifier,
- const std::string& trace,
- const std::string& values,
- const std::string& prefix,
- const std::string& suffix,
- const std::string& units,
- bool important);
-
protected:
AutomationProxy* automation() {
EXPECT_TRUE(server_.get());
diff --git a/chrome/test/ui/v8_benchmark_uitest.cc b/chrome/test/ui/v8_benchmark_uitest.cc
index 737de98..5043642 100644
--- a/chrome/test/ui/v8_benchmark_uitest.cc
+++ b/chrome/test/ui/v8_benchmark_uitest.cc
@@ -14,7 +14,7 @@
#include "chrome/common/json_value_serializer.h"
#include "chrome/test/automation/tab_proxy.h"
#include "chrome/test/ui/javascript_test_util.h"
-#include "chrome/test/ui/ui_test.h"
+#include "chrome/test/ui/ui_perf_test.h"
#include "googleurl/src/gurl.h"
#include "net/base/net_util.h"
@@ -25,7 +25,7 @@ static const FilePath::CharType kStartFile[] =
const char kRunV8Benchmark[] = "run-v8-benchmark";
-class V8BenchmarkTest : public UITest {
+class V8BenchmarkTest : public UIPerfTest {
public:
typedef std::map<std::string, std::string> ResultsMap;