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

Unified Diff: chrome/browser/private_working_set_snapshot_win_unittest.cc

Issue 1181263005: Make task manager memory data more efficient and meaningful. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adjust high threshold so it works with Dr Memory. Created 5 years, 5 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/private_working_set_snapshot_win.cc ('k') | chrome/browser/task_manager/task_manager.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/private_working_set_snapshot_win_unittest.cc
diff --git a/chrome/browser/private_working_set_snapshot_win_unittest.cc b/chrome/browser/private_working_set_snapshot_win_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..2c8bd51e65347d84957081d1b14e17583dc0df35
--- /dev/null
+++ b/chrome/browser/private_working_set_snapshot_win_unittest.cc
@@ -0,0 +1,55 @@
+// Copyright 2015 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/browser/private_working_set_snapshot.h"
+
+#include "base/win/windows_version.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+using PrivateWorkingSetSnapshotWinTest = testing::Test;
+
+TEST_F(PrivateWorkingSetSnapshotWinTest, FindPidSelfTest) {
+ // The Pdh APIs are supported on Windows XP and above, but the "Working Set -
+ // Private" counter that PrivateWorkingSetSnapshot depends on is not defined
+ // until Windows Vista and is not reliable until Windows 7. Early-out to avoid
+ // test failure.
+ if (base::win::GetVersion() <= base::win::VERSION_VISTA)
+ return;
+
+ // Sample this process.
+ base::ProcessId pid = base::GetCurrentProcId();
+
+ PrivateWorkingSetSnapshot private_ws_snapshot;
+
+ private_ws_snapshot.AddToMonitorList("unit_tests");
+ private_ws_snapshot.Sample();
+
+ size_t private_ws = private_ws_snapshot.GetPrivateWorkingSet(pid);
+ // Private working set is difficult to predict but should be at least several
+ // MB. Initial tests show a value of 19+ MB depending on how many tests and
+ // processes are used. Anomalously small or large values would warrant
+ // investigation.
+ EXPECT_GT(private_ws, 2000000u);
+ // Check that the WS is less than 1500 MB. This is set very high to reduce the
+ // chance that unrelated changes could ever make this fail. This mostly just
+ // checks against some uncaught error that might return 0xFFFFFFFF. When run
+ // under Dr Memory the private working set was seen to be about 850 MB, which
+ // is why such a high threshold has been chosen.
+ EXPECT_LT(private_ws, 1500000000u);
+
+ // Allocate and touch a large block of memory (vector's constructor will zero
+ // every entry). This will increase the private working set.
+ const size_t alloc_size = 10000000;
+ std::vector<char> big_memory(alloc_size);
+
+ size_t private_ws2 = private_ws_snapshot.GetPrivateWorkingSet(pid);
+ EXPECT_EQ(private_ws, private_ws2) << "GetPrivateWorkingSet should be "
+ "consistent until the next call to "
+ "Sample()";
+
+ private_ws_snapshot.Sample();
+ size_t private_ws3 = private_ws_snapshot.GetPrivateWorkingSet(pid);
+ EXPECT_GT(private_ws3, private_ws2 + alloc_size / 2)
+ << "GetPrivateWorkingSet should increase as we allocate more memory";
+}
« no previous file with comments | « chrome/browser/private_working_set_snapshot_win.cc ('k') | chrome/browser/task_manager/task_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698