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

Side by Side Diff: content/child/child_thread_impl_browsertest.cc

Issue 2541573002: Count discardable memory in browsertest
Patch Set: Created 4 years 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 | « no previous file | 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 "content/child/child_thread_impl.h" 5 #include "content/child/child_thread_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <string.h> 8 #include <string.h>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 ScopedVector<base::DiscardableMemory> instances; 87 ScopedVector<base::DiscardableMemory> instances;
88 for (size_t i = 0; i < kNumberOfInstances; ++i) { 88 for (size_t i = 0; i < kNumberOfInstances; ++i) {
89 std::unique_ptr<base::DiscardableMemory> memory = 89 std::unique_ptr<base::DiscardableMemory> memory =
90 child_discardable_shared_memory_manager() 90 child_discardable_shared_memory_manager()
91 ->AllocateLockedDiscardableMemory(kLargeSize); 91 ->AllocateLockedDiscardableMemory(kLargeSize);
92 ASSERT_TRUE(memory); 92 ASSERT_TRUE(memory);
93 void* addr = memory->data(); 93 void* addr = memory->data();
94 ASSERT_NE(nullptr, addr); 94 ASSERT_NE(nullptr, addr);
95 memory->Unlock(); 95 memory->Unlock();
96 instances.push_back(std::move(memory)); 96 instances.push_back(std::move(memory));
97
98 if (i % 10 == 0) {
99 size_t s = 0;
100 for (auto& m : instances) {
101 if (m->Lock()) {
102 s += kLargeSize;
103 m->Unlock();
104 }
105 }
106 fprintf(stderr, "EEE s=%luMB\n", s / 1024/1024);
107 }
97 } 108 }
98 } 109 }
99 110
100 IN_PROC_BROWSER_TEST_F(ChildThreadImplBrowserTest, 111 IN_PROC_BROWSER_TEST_F(ChildThreadImplBrowserTest,
101 ReleaseFreeDiscardableMemory) { 112 ReleaseFreeDiscardableMemory) {
102 const size_t kSize = 1024 * 1024; // 1MiB. 113 const size_t kSize = 1024 * 1024; // 1MiB.
103 114
104 std::unique_ptr<base::DiscardableMemory> memory = 115 std::unique_ptr<base::DiscardableMemory> memory =
105 child_discardable_shared_memory_manager() 116 child_discardable_shared_memory_manager()
106 ->AllocateLockedDiscardableMemory(kSize); 117 ->AllocateLockedDiscardableMemory(kSize);
(...skipping 14 matching lines...) Expand all
121 if (!discardable_memory::DiscardableSharedMemoryManager::current() 132 if (!discardable_memory::DiscardableSharedMemoryManager::current()
122 ->GetBytesAllocated()) 133 ->GetBytesAllocated())
123 break; 134 break;
124 } 135 }
125 136
126 EXPECT_LT(base::TimeTicks::Now(), end); 137 EXPECT_LT(base::TimeTicks::Now(), end);
127 } 138 }
128 139
129 } // namespace 140 } // namespace
130 } // namespace content 141 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698