OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // | 2 // |
3 // Tests for heap profiler | 3 // Tests for heap profiler |
4 | 4 |
5 #ifdef ENABLE_LOGGING_AND_PROFILING | 5 #ifdef ENABLE_LOGGING_AND_PROFILING |
6 | 6 |
7 #include "v8.h" | 7 #include "v8.h" |
8 | 8 |
9 #include "cctest.h" | 9 #include "cctest.h" |
10 #include "heap-profiler.h" | 10 #include "heap-profiler.h" |
(...skipping 1354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1365 "document = { URL: new URLWithException() };"); | 1365 "document = { URL: new URLWithException() };"); |
1366 const v8::HeapSnapshot* snapshot = | 1366 const v8::HeapSnapshot* snapshot = |
1367 v8::HeapProfiler::TakeSnapshot(v8::String::New("document")); | 1367 v8::HeapProfiler::TakeSnapshot(v8::String::New("document")); |
1368 const v8::HeapGraphNode* global = GetGlobalObject(snapshot); | 1368 const v8::HeapGraphNode* global = GetGlobalObject(snapshot); |
1369 CHECK_NE(NULL, global); | 1369 CHECK_NE(NULL, global); |
1370 CHECK_EQ("Object", | 1370 CHECK_EQ("Object", |
1371 const_cast<i::HeapEntry*>( | 1371 const_cast<i::HeapEntry*>( |
1372 reinterpret_cast<const i::HeapEntry*>(global))->name()); | 1372 reinterpret_cast<const i::HeapEntry*>(global))->name()); |
1373 } | 1373 } |
1374 | 1374 |
| 1375 |
| 1376 TEST(NodesIteration) { |
| 1377 v8::HandleScope scope; |
| 1378 LocalContext env; |
| 1379 const v8::HeapSnapshot* snapshot = |
| 1380 v8::HeapProfiler::TakeSnapshot(v8::String::New("iteration")); |
| 1381 const v8::HeapGraphNode* global = GetGlobalObject(snapshot); |
| 1382 CHECK_NE(NULL, global); |
| 1383 // Verify that we can find this object by iteration. |
| 1384 const int nodes_count = snapshot->GetNodesCount(); |
| 1385 int count = 0; |
| 1386 for (int i = 0; i < nodes_count; ++i) { |
| 1387 if (snapshot->GetNode(i) == global) |
| 1388 ++count; |
| 1389 } |
| 1390 CHECK_EQ(1, count); |
| 1391 } |
| 1392 |
1375 #endif // ENABLE_LOGGING_AND_PROFILING | 1393 #endif // ENABLE_LOGGING_AND_PROFILING |
OLD | NEW |