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

Side by Side Diff: chrome/test/memory_test/memory_test.cc

Issue 371025: More memory stats code cleanup:... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: multiply uses by 1024 to keep stats consistent with old runs Created 11 years, 1 month 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
OLDNEW
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2009 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"
11 #include "base/string_util.h" 11 #include "base/string_util.h"
12 #include "chrome/browser/net/url_fixer_upper.h" 12 #include "chrome/browser/net/url_fixer_upper.h"
13 #include "chrome/common/chrome_constants.h" 13 #include "chrome/common/chrome_constants.h"
14 #include "chrome/common/chrome_paths.h" 14 #include "chrome/common/chrome_paths.h"
15 #include "chrome/common/chrome_switches.h" 15 #include "chrome/common/chrome_switches.h"
16 #include "chrome/test/automation/browser_proxy.h" 16 #include "chrome/test/automation/browser_proxy.h"
17 #include "chrome/test/automation/tab_proxy.h" 17 #include "chrome/test/automation/tab_proxy.h"
18 #include "chrome/test/automation/window_proxy.h" 18 #include "chrome/test/automation/window_proxy.h"
19 #include "chrome/test/chrome_process_util.h" 19 #include "chrome/test/chrome_process_util.h"
20 #include "chrome/test/ui/ui_test.h" 20 #include "chrome/test/ui/ui_test.h"
21 #include "chrome/test/perf/mem_usage.h"
22 #include "googleurl/src/gurl.h" 21 #include "googleurl/src/gurl.h"
23 #include "net/base/net_util.h" 22 #include "net/base/net_util.h"
24 #include "testing/gtest/include/gtest/gtest.h" 23 #include "testing/gtest/include/gtest/gtest.h"
25 24
26 namespace { 25 namespace {
27 26
28 static const FilePath::CharType kTempDirName[] = 27 static const FilePath::CharType kTempDirName[] =
29 FILE_PATH_LITERAL("memory_test_profile"); 28 FILE_PATH_LITERAL("memory_test_profile");
30 29
31 class MemoryTest : public UITest { 30 class MemoryTest : public UITest {
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 // new tab. 127 // new tab.
129 // <PAUSE> is a special URL that informs the loop to pause before proceeding 128 // <PAUSE> is a special URL that informs the loop to pause before proceeding
130 // to the next URL. 129 // to the next URL.
131 void RunTest(const char* test_name, int num_target_tabs) { 130 void RunTest(const char* test_name, int num_target_tabs) {
132 std::string* urls; 131 std::string* urls;
133 size_t urls_length = GetUrlList(&urls); 132 size_t urls_length = GetUrlList(&urls);
134 133
135 // Record the initial CommitCharge. This is a system-wide measurement, 134 // Record the initial CommitCharge. This is a system-wide measurement,
136 // so if other applications are running, they can create variance in this 135 // so if other applications are running, they can create variance in this
137 // test. 136 // test.
138 size_t start_size = GetSystemCommitCharge(); 137 size_t start_size = base::GetSystemCommitCharge();
139 138
140 // Cycle through the URLs. 139 // Cycle through the URLs.
141 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); 140 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0));
142 int active_window = 0; // The index of the window we are currently using. 141 int active_window = 0; // The index of the window we are currently using.
143 scoped_refptr<TabProxy> tab(window->GetActiveTab()); 142 scoped_refptr<TabProxy> tab(window->GetActiveTab());
144 int expected_tab_count = 1; 143 int expected_tab_count = 1;
145 for (unsigned counter = 0; counter < urls_length; ++counter) { 144 for (unsigned counter = 0; counter < urls_length; ++counter) {
146 std::string url = urls[counter]; 145 std::string url = urls[counter];
147 146
148 if (url == "<PAUSE>") { // Special command to delay on this page 147 if (url == "<PAUSE>") { // Special command to delay on this page
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 &timed_out); 213 &timed_out);
215 if (timed_out) 214 if (timed_out)
216 printf("warning: %s timed out!\n", urls[counter].c_str()); 215 printf("warning: %s timed out!\n", urls[counter].c_str());
217 216
218 // TODO(mbelshe): Bug 2953 217 // TODO(mbelshe): Bug 2953
219 // The automation crashes periodically if we cycle too quickly. 218 // The automation crashes periodically if we cycle too quickly.
220 // To make these tests more reliable, slowing them down a bit. 219 // To make these tests more reliable, slowing them down a bit.
221 PlatformThread::Sleep(100); 220 PlatformThread::Sleep(100);
222 } 221 }
223 222
224 size_t stop_size = GetSystemCommitCharge(); 223 size_t stop_size = base::GetSystemCommitCharge();
225 PrintResults(test_name, stop_size - start_size); 224 PrintResults(test_name, (stop_size - start_size) / 1024);
226 } 225 }
227 226
228 void PrintResults(const char* test_name, size_t commit_size) { 227 void PrintResults(const char* test_name, size_t commit_size) {
229 PrintMemoryUsageInfo(test_name); 228 PrintMemoryUsageInfo(test_name);
230 std::string trace_name(test_name); 229 std::string trace_name(test_name);
231 trace_name.append("_cc"); 230 trace_name.append("_cc");
232 231
233 PrintResult("commit_charge", "", trace_name, 232 PrintResult("commit_charge", "", trace_name,
234 commit_size / 1024, "kb", true /* important */); 233 commit_size / 1024, "kb", true /* important */);
235 } 234 }
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
645 TEST_F(GeneralMixMemoryTest, TwelveTabTest) { 644 TEST_F(GeneralMixMemoryTest, TwelveTabTest) {
646 RunTest("12t", 12); 645 RunTest("12t", 12);
647 } 646 }
648 647
649 // Commented out until the recorded cache data is added. 648 // Commented out until the recorded cache data is added.
650 //TEST_F(MembusterMemoryTest, Windows) { 649 //TEST_F(MembusterMemoryTest, Windows) {
651 // RunTest("membuster", 0); 650 // RunTest("membuster", 0);
652 //} 651 //}
653 652
654 } // namespace 653 } // namespace
OLDNEW
« base/process_util_win.cc ('K') | « chrome/chrome.gyp ('k') | chrome/test/perf/mem_usage.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698