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

Unified Diff: test/cctest/test-heap.cc

Issue 4888001: Provide more accurate results about used heap size via GetHeapStatistics. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix Slava's comments Created 10 years, 1 month 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 | « src/spaces.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-heap.cc
diff --git a/test/cctest/test-heap.cc b/test/cctest/test-heap.cc
index 94d05555ec556276834a381ad68786266f433e77..fbe66ecd74627eade4ea57fe233b3f50ff21e33d 100644
--- a/test/cctest/test-heap.cc
+++ b/test/cctest/test-heap.cc
@@ -1095,3 +1095,32 @@ TEST(TestInternalWeakListsTraverseWithGC) {
ctx[i]->Exit();
}
}
+
+
+TEST(TestSizeOfObjectsVsHeapIteratorPrecision) {
+ InitializeVM();
+ intptr_t size_of_objects_1 = Heap::SizeOfObjects();
+ HeapIterator iterator(HeapIterator::kPreciseFiltering);
+ intptr_t size_of_objects_2 = 0;
+ for (HeapObject* obj = iterator.next();
+ obj != NULL;
+ obj = iterator.next()) {
+ size_of_objects_2 += obj->Size();
+ }
+ // Delta must be within 1% of the larger result.
+ if (size_of_objects_1 > size_of_objects_2) {
+ intptr_t delta = size_of_objects_1 - size_of_objects_2;
+ PrintF("Heap::SizeOfObjects: %" V8_PTR_PREFIX "d, "
+ "Iterator: %" V8_PTR_PREFIX "d, "
+ "delta: %" V8_PTR_PREFIX "d\n",
+ size_of_objects_1, size_of_objects_2, delta);
+ CHECK_GT(size_of_objects_1 / 100, delta);
+ } else {
+ intptr_t delta = size_of_objects_2 - size_of_objects_1;
+ PrintF("Heap::SizeOfObjects: %" V8_PTR_PREFIX "d, "
+ "Iterator: %" V8_PTR_PREFIX "d, "
+ "delta: %" V8_PTR_PREFIX "d\n",
+ size_of_objects_1, size_of_objects_2, delta);
+ CHECK_GT(size_of_objects_2 / 100, delta);
+ }
+}
« no previous file with comments | « src/spaces.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698