diff options
author | sgk@chromium.org <sgk@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-05 22:31:12 +0000 |
---|---|---|
committer | sgk@chromium.org <sgk@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-05 22:31:12 +0000 |
commit | b429982e9e25eafd853036f210c299a0ea56585a (patch) | |
tree | 24a3fd58ffc47e7db870d08723ce0244aebe15c0 /chrome_frame/test/perf | |
parent | 157d547807a2b9d0e42f17636ffc39336a9a62f6 (diff) | |
download | chromium_src-b429982e9e25eafd853036f210c299a0ea56585a.zip chromium_src-b429982e9e25eafd853036f210c299a0ea56585a.tar.gz chromium_src-b429982e9e25eafd853036f210c299a0ea56585a.tar.bz2 |
Get rid of GetMemoryInfo() in favor of using base::ProcessMetrics.
Use a test-specific subclass to isolate the stopgap use of 'ps'
to collect memory stats on Mac.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/342070
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31144 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame/test/perf')
-rw-r--r-- | chrome_frame/test/perf/chrome_frame_perftest.cc | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/chrome_frame/test/perf/chrome_frame_perftest.cc b/chrome_frame/test/perf/chrome_frame_perftest.cc index 215f076..968bb6d 100644 --- a/chrome_frame/test/perf/chrome_frame_perftest.cc +++ b/chrome_frame/test/perf/chrome_frame_perftest.cc @@ -12,6 +12,7 @@ #include "chrome_tab.h" // Generated from chrome_tab.idl. #include "base/file_util.h" +#include "base/process_util.h" #include "base/registry.h" #include "base/scoped_ptr.h" #include "base/scoped_bstr_win.h" @@ -488,9 +489,7 @@ class ChromeFrameMemoryTest : public ChromeFramePerfTestBase { // Added to enable us to add ProcessMemoryInfo instances to a map. ProcessMemoryInfo() : process_id_(0), - peak_virtual_size_(0), virtual_size_(0), - peak_working_set_size_(0), working_set_size_(0), chrome_browser_process_(false), chrome_frame_memory_test_instance_(NULL) {} @@ -498,19 +497,31 @@ class ChromeFrameMemoryTest : public ChromeFramePerfTestBase { ProcessMemoryInfo(base::ProcessId process_id, bool chrome_browser_process, ChromeFrameMemoryTest* memory_test_instance) : process_id_(process_id), - peak_virtual_size_(0), virtual_size_(0), - peak_working_set_size_(0), working_set_size_(0), chrome_browser_process_(chrome_browser_process), chrome_frame_memory_test_instance_(memory_test_instance) {} bool GetMemoryConsumptionDetails() { - return GetMemoryInfo(process_id_, - &peak_virtual_size_, - &virtual_size_, - &peak_working_set_size_, - &working_set_size_); + base::ProcessHandle process_handle; + if (!base::OpenPrivilegedProcessHandle(process_id_, &process_handle)) { + NOTREACHED(); + } + + // TODO(sgk): if/when base::ProcessMetrics can return real memory + // stats on mac, convert to: + // + // scoped_ptr<base::ProcessMetrics> process_metrics; + // process_metrics.reset( + // base::ProcessMetrics::CreateProcessMetrics(process_handle)); + scoped_ptr<ChromeTestProcessMetrics> process_metrics; + process_metrics.reset( + ChromeTestProcessMetrics::CreateProcessMetrics(process_handle)); + + virtual_size_ = process_metrics->GetPagefileUsage(); + working_set_size_ = process_metrics->GetWorkingSetSize(); + + return true; } void Print(const char* test_name) { @@ -538,9 +549,7 @@ class ChromeFrameMemoryTest : public ChromeFramePerfTestBase { } int process_id_; - size_t peak_virtual_size_; size_t virtual_size_; - size_t peak_working_set_size_; size_t working_set_size_; // Set to true if this is the chrome browser process. bool chrome_browser_process_; |