Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/tracing/common/process_metrics_memory_dump_provider.h" | 5 #include "components/tracing/common/process_metrics_memory_dump_provider.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| 11 #include "base/files/file_util.h" | 11 #include "base/files/file_util.h" |
| 12 #include "base/trace_event/process_memory_dump.h" | 12 #include "base/trace_event/process_memory_dump.h" |
| 13 #include "base/trace_event/process_memory_maps.h" | 13 #include "base/trace_event/process_memory_maps.h" |
| 14 #include "base/trace_event/process_memory_totals.h" | 14 #include "base/trace_event/process_memory_totals.h" |
| 15 #include "base/trace_event/trace_config_memory_test_util.h" | |
| 15 #include "base/trace_event/trace_event_argument.h" | 16 #include "base/trace_event/trace_event_argument.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 17 | 18 |
| 18 namespace tracing { | 19 namespace tracing { |
| 19 | 20 |
| 20 #if defined(OS_LINUX) || defined(OS_ANDROID) | 21 #if defined(OS_LINUX) || defined(OS_ANDROID) |
| 21 namespace { | 22 namespace { |
| 22 const char kTestSmaps1[] = | 23 const char kTestSmaps1[] = |
| 23 "00400000-004be000 r-xp 00000000 fc:01 1234 /file/1\n" | 24 "00400000-004be000 r-xp 00000000 fc:01 1234 /file/1\n" |
| 24 "Size: 760 kB\n" | 25 "Size: 760 kB\n" |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 227 EXPECT_EQ("", regions_2[0].mapped_file); | 228 EXPECT_EQ("", regions_2[0].mapped_file); |
| 228 EXPECT_EQ(32 * 1024UL, regions_2[0].byte_stats_proportional_resident); | 229 EXPECT_EQ(32 * 1024UL, regions_2[0].byte_stats_proportional_resident); |
| 229 EXPECT_EQ(16 * 1024UL, regions_2[0].byte_stats_shared_clean_resident); | 230 EXPECT_EQ(16 * 1024UL, regions_2[0].byte_stats_shared_clean_resident); |
| 230 EXPECT_EQ(12 * 1024UL, regions_2[0].byte_stats_shared_dirty_resident); | 231 EXPECT_EQ(12 * 1024UL, regions_2[0].byte_stats_shared_dirty_resident); |
| 231 EXPECT_EQ(8 * 1024UL, regions_2[0].byte_stats_private_clean_resident); | 232 EXPECT_EQ(8 * 1024UL, regions_2[0].byte_stats_private_clean_resident); |
| 232 EXPECT_EQ(4 * 1024UL, regions_2[0].byte_stats_private_dirty_resident); | 233 EXPECT_EQ(4 * 1024UL, regions_2[0].byte_stats_private_dirty_resident); |
| 233 EXPECT_EQ(0 * 1024UL, regions_2[0].byte_stats_swapped); | 234 EXPECT_EQ(0 * 1024UL, regions_2[0].byte_stats_swapped); |
| 234 } | 235 } |
| 235 #endif // defined(OS_LINUX) || defined(OS_ANDROID) | 236 #endif // defined(OS_LINUX) || defined(OS_ANDROID) |
| 236 | 237 |
| 238 TEST(ProcessMetricsMemoryDumpProviderTest, TestPollFastMemoryTotal) { | |
| 239 ProcessMetricsMemoryDumpProvider mdp(base::kNullProcessId); | |
| 240 mdp.SetFastMemoryPollingEnabled(true); | |
| 241 uint64_t value; | |
| 242 for (int i = 0; i < 4; i++) { | |
|
Primiano Tucci (use gerrit)
2016/12/13 20:02:39
I think a slighly better approach would be:
PollFa
ssid
2016/12/14 02:59:32
Done.
ssid
2016/12/14 06:18:58
Release builds do not make the memory resident eve
| |
| 243 mdp.PollFastMemoryTotal(&value); | |
| 244 EXPECT_GT(value, 0u); | |
| 245 } | |
| 246 #if defined(OS_LINUX) || defined(OS_ANDROID) | |
| 247 EXPECT_GT(mdp.proc_statm_file_, 0); | |
|
Primiano Tucci (use gerrit)
2016/12/13 20:02:39
s/GT/GE/.
In an extremely unlikely scenario, one m
ssid
2016/12/14 02:59:32
Done.
| |
| 248 mdp.SetFastMemoryPollingEnabled(false); | |
| 249 EXPECT_EQ(-1, mdp.proc_statm_file_); | |
| 250 #else | |
| 251 mdp.SetFastMemoryPollingEnabled(false); | |
| 252 #endif | |
| 253 } | |
| 254 | |
| 237 } // namespace tracing | 255 } // namespace tracing |
| OLD | NEW |