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

Unified Diff: base/trace_event/memory_usage_estimator_unittest.cc

Issue 2676043002: [memory-infra] Add EstimateMemoryUsage() for deque and friends. (Closed)
Patch Set: Created 3 years, 10 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 | « base/trace_event/memory_usage_estimator.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/trace_event/memory_usage_estimator_unittest.cc
diff --git a/base/trace_event/memory_usage_estimator_unittest.cc b/base/trace_event/memory_usage_estimator_unittest.cc
index b77d5fdc9797f3167131bc01e0520afc6a3b5503..80237c0192fa780acfa067a0461f9fe13b927b3d 100644
--- a/base/trace_event/memory_usage_estimator_unittest.cc
+++ b/base/trace_event/memory_usage_estimator_unittest.cc
@@ -225,5 +225,20 @@ TEST(EstimateMemoryUsageTest, UnorderedMultiMap) {
EXPECT_EQ_32_64(515540u, 531580u, EstimateMemoryUsage(map));
}
+TEST(EstimateMemoryUsageTest, Deque) {
+ std::deque<Data> deque;
+
+ // Pick a large value so that platform-specific accounting
+ // for deque's blocks is small compared to usage of all items.
+ constexpr size_t kDataSize = 100000;
+ for (int i = 0; i != 1500; ++i) {
+ deque.push_back(Data(kDataSize));
+ }
+
+ // Compare against a reasonable minimum (i.e. no overhead).
+ size_t min_expected_usage = deque.size() * (sizeof(Data) + kDataSize);
+ EXPECT_LE(min_expected_usage, EstimateMemoryUsage(deque));
+}
+
} // namespace trace_event
} // namespace base
« no previous file with comments | « base/trace_event/memory_usage_estimator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698