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

Side by Side Diff: base/trace_event/process_memory_dump_unittest.cc

Issue 1793943002: Use sysctlbyname() to get kernel page size. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed primiano's comments Created 4 years, 9 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 unified diff | Download patch
« no previous file with comments | « base/trace_event/process_memory_dump.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/trace_event/process_memory_dump.h" 5 #include "base/trace_event/process_memory_dump.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/memory/aligned_memory.h" 9 #include "base/memory/aligned_memory.h"
10 #include "base/process/process_metrics.h" 10 #include "base/process/process_metrics.h"
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 ASSERT_EQ(shared_mad1, shared_mad4); 216 ASSERT_EQ(shared_mad1, shared_mad4);
217 ASSERT_EQ(MemoryAllocatorDump::Flags::DEFAULT, shared_mad1->flags()); 217 ASSERT_EQ(MemoryAllocatorDump::Flags::DEFAULT, shared_mad1->flags());
218 218
219 auto shared_mad5 = pmd->CreateWeakSharedGlobalAllocatorDump(shared_mad_guid); 219 auto shared_mad5 = pmd->CreateWeakSharedGlobalAllocatorDump(shared_mad_guid);
220 ASSERT_EQ(shared_mad1, shared_mad5); 220 ASSERT_EQ(shared_mad1, shared_mad5);
221 ASSERT_EQ(MemoryAllocatorDump::Flags::DEFAULT, shared_mad1->flags()); 221 ASSERT_EQ(MemoryAllocatorDump::Flags::DEFAULT, shared_mad1->flags());
222 } 222 }
223 223
224 #if defined(COUNT_RESIDENT_BYTES_SUPPORTED) 224 #if defined(COUNT_RESIDENT_BYTES_SUPPORTED)
225 TEST(ProcessMemoryDumpTest, CountResidentBytes) { 225 TEST(ProcessMemoryDumpTest, CountResidentBytes) {
226 const size_t page_size = base::GetPageSize(); 226 const size_t page_size = ProcessMemoryDump::GetSystemPageSize();
227 227
228 // Allocate few page of dirty memory and check if it is resident. 228 // Allocate few page of dirty memory and check if it is resident.
229 const size_t size1 = 5 * page_size; 229 const size_t size1 = 5 * page_size;
230 scoped_ptr<char, base::AlignedFreeDeleter> memory1( 230 scoped_ptr<char, base::AlignedFreeDeleter> memory1(
231 static_cast<char*>(base::AlignedAlloc(size1, page_size))); 231 static_cast<char*>(base::AlignedAlloc(size1, page_size)));
232 memset(memory1.get(), 0, size1); 232 memset(memory1.get(), 0, size1);
233 size_t res1 = ProcessMemoryDump::CountResidentBytes(memory1.get(), size1); 233 size_t res1 = ProcessMemoryDump::CountResidentBytes(memory1.get(), size1);
234 ASSERT_EQ(res1, size1); 234 ASSERT_EQ(res1, size1);
235 235
236 // Allocate a large memory segment (> 8Mib). 236 // Allocate a large memory segment (> 8Mib).
237 const size_t kVeryLargeMemorySize = 15 * 1024 * 1024; 237 const size_t kVeryLargeMemorySize = 15 * 1024 * 1024;
238 scoped_ptr<char, base::AlignedFreeDeleter> memory2( 238 scoped_ptr<char, base::AlignedFreeDeleter> memory2(
239 static_cast<char*>(base::AlignedAlloc(kVeryLargeMemorySize, page_size))); 239 static_cast<char*>(base::AlignedAlloc(kVeryLargeMemorySize, page_size)));
240 memset(memory2.get(), 0, kVeryLargeMemorySize); 240 memset(memory2.get(), 0, kVeryLargeMemorySize);
241 size_t res2 = ProcessMemoryDump::CountResidentBytes(memory2.get(), 241 size_t res2 = ProcessMemoryDump::CountResidentBytes(memory2.get(),
242 kVeryLargeMemorySize); 242 kVeryLargeMemorySize);
243 ASSERT_EQ(res2, kVeryLargeMemorySize); 243 ASSERT_EQ(res2, kVeryLargeMemorySize);
244 } 244 }
245 #endif // defined(COUNT_RESIDENT_BYTES_SUPPORTED) 245 #endif // defined(COUNT_RESIDENT_BYTES_SUPPORTED)
246 246
247 } // namespace trace_event 247 } // namespace trace_event
248 } // namespace base 248 } // namespace base
OLDNEW
« no previous file with comments | « base/trace_event/process_memory_dump.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698