Index: test/cctest/test-heap.cc |
diff --git a/test/cctest/test-heap.cc b/test/cctest/test-heap.cc |
index e476bcca84665990347988a1780298a134086fe5..dfabb92b9894ebf986f43d0b8239b68c81bbd60f 100644 |
--- a/test/cctest/test-heap.cc |
+++ b/test/cctest/test-heap.cc |
@@ -31,6 +31,7 @@ |
#include "src/v8.h" |
#include "src/compilation-cache.h" |
+#include "src/context-measure.h" |
#include "src/deoptimizer.h" |
#include "src/execution.h" |
#include "src/factory.h" |
@@ -6268,3 +6269,30 @@ TEST(SlotsBufferObjectSlotsRemoval) { |
FixedArrayBase::kLengthOffset)); |
delete buffer; |
} |
+ |
+ |
+TEST(ContextMeasure) { |
+ CcTest::InitializeVM(); |
+ v8::HandleScope scope(CcTest::isolate()); |
+ Isolate* isolate = CcTest::i_isolate(); |
+ LocalContext context; |
+ |
+ int size_upper_limit = 0; |
+ int count_upper_limit = 0; |
+ HeapIterator it(CcTest::heap()); |
+ for (HeapObject* obj = it.next(); obj != NULL; obj = it.next()) { |
+ size_upper_limit += obj->Size(); |
+ count_upper_limit++; |
+ } |
+ |
+ ContextMeasure measure(*isolate->native_context()); |
+ |
+ PrintF("Context size : %d bytes\n", measure.Size()); |
+ PrintF("Context object count: %d\n", measure.Count()); |
+ |
+ CHECK_LE(1000, measure.Count()); |
+ CHECK_LE(50000, measure.Size()); |
+ |
+ CHECK_LE(measure.Count(), count_upper_limit); |
+ CHECK_LE(measure.Size(), size_upper_limit); |
+} |