OLD | NEW |
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 #include "heap-profiler.h" | 8 #include "heap-profiler.h" |
9 #include "snapshot.h" | 9 #include "snapshot.h" |
10 #include "string-stream.h" | 10 #include "string-stream.h" |
(...skipping 1377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1388 CHECK_EQ(1, ccc->GetChildrenCount()); | 1388 CHECK_EQ(1, ccc->GetChildrenCount()); |
1389 const v8::HeapGraphNode* n_CCC = GetNode( | 1389 const v8::HeapGraphNode* n_CCC = GetNode( |
1390 ccc, v8::HeapGraphNode::kString, "CCC"); | 1390 ccc, v8::HeapGraphNode::kString, "CCC"); |
1391 CHECK_NE(NULL, n_CCC); | 1391 CHECK_NE(NULL, n_CCC); |
1392 | 1392 |
1393 CHECK_EQ(aaa, GetProperty(n_AAA, v8::HeapGraphEdge::kInternal, "Native")); | 1393 CHECK_EQ(aaa, GetProperty(n_AAA, v8::HeapGraphEdge::kInternal, "Native")); |
1394 CHECK_EQ(aaa, GetProperty(n_BBB, v8::HeapGraphEdge::kInternal, "Native")); | 1394 CHECK_EQ(aaa, GetProperty(n_BBB, v8::HeapGraphEdge::kInternal, "Native")); |
1395 CHECK_EQ(ccc, GetProperty(n_CCC, v8::HeapGraphEdge::kInternal, "Native")); | 1395 CHECK_EQ(ccc, GetProperty(n_CCC, v8::HeapGraphEdge::kInternal, "Native")); |
1396 } | 1396 } |
1397 | 1397 |
| 1398 |
| 1399 TEST(DeleteAllHeapSnapshots) { |
| 1400 v8::HandleScope scope; |
| 1401 LocalContext env; |
| 1402 |
| 1403 CHECK_EQ(0, v8::HeapProfiler::GetSnapshotsCount()); |
| 1404 v8::HeapProfiler::DeleteAllSnapshots(); |
| 1405 CHECK_EQ(0, v8::HeapProfiler::GetSnapshotsCount()); |
| 1406 CHECK_NE(NULL, v8::HeapProfiler::TakeSnapshot(v8::String::New("1"))); |
| 1407 CHECK_EQ(1, v8::HeapProfiler::GetSnapshotsCount()); |
| 1408 v8::HeapProfiler::DeleteAllSnapshots(); |
| 1409 CHECK_EQ(0, v8::HeapProfiler::GetSnapshotsCount()); |
| 1410 CHECK_NE(NULL, v8::HeapProfiler::TakeSnapshot(v8::String::New("1"))); |
| 1411 CHECK_NE(NULL, v8::HeapProfiler::TakeSnapshot(v8::String::New("2"))); |
| 1412 CHECK_EQ(2, v8::HeapProfiler::GetSnapshotsCount()); |
| 1413 v8::HeapProfiler::DeleteAllSnapshots(); |
| 1414 CHECK_EQ(0, v8::HeapProfiler::GetSnapshotsCount()); |
| 1415 } |
| 1416 |
| 1417 |
| 1418 TEST(DeleteHeapSnapshot) { |
| 1419 v8::HandleScope scope; |
| 1420 LocalContext env; |
| 1421 |
| 1422 CHECK_EQ(0, v8::HeapProfiler::GetSnapshotsCount()); |
| 1423 const v8::HeapSnapshot* s1 = |
| 1424 v8::HeapProfiler::TakeSnapshot(v8::String::New("1")); |
| 1425 CHECK_NE(NULL, s1); |
| 1426 CHECK_EQ(1, v8::HeapProfiler::GetSnapshotsCount()); |
| 1427 unsigned uid1 = s1->GetUid(); |
| 1428 CHECK_EQ(s1, v8::HeapProfiler::FindSnapshot(uid1)); |
| 1429 s1->Delete(); |
| 1430 CHECK_EQ(0, v8::HeapProfiler::GetSnapshotsCount()); |
| 1431 CHECK_EQ(NULL, v8::HeapProfiler::FindSnapshot(uid1)); |
| 1432 |
| 1433 const v8::HeapSnapshot* s2 = |
| 1434 v8::HeapProfiler::TakeSnapshot(v8::String::New("2")); |
| 1435 CHECK_NE(NULL, s2); |
| 1436 CHECK_EQ(1, v8::HeapProfiler::GetSnapshotsCount()); |
| 1437 unsigned uid2 = s2->GetUid(); |
| 1438 CHECK_NE(static_cast<int>(uid1), static_cast<int>(uid2)); |
| 1439 CHECK_EQ(s2, v8::HeapProfiler::FindSnapshot(uid2)); |
| 1440 const v8::HeapSnapshot* s3 = |
| 1441 v8::HeapProfiler::TakeSnapshot(v8::String::New("3")); |
| 1442 CHECK_NE(NULL, s3); |
| 1443 CHECK_EQ(2, v8::HeapProfiler::GetSnapshotsCount()); |
| 1444 unsigned uid3 = s3->GetUid(); |
| 1445 CHECK_NE(static_cast<int>(uid1), static_cast<int>(uid3)); |
| 1446 CHECK_EQ(s3, v8::HeapProfiler::FindSnapshot(uid3)); |
| 1447 s2->Delete(); |
| 1448 CHECK_EQ(1, v8::HeapProfiler::GetSnapshotsCount()); |
| 1449 CHECK_EQ(NULL, v8::HeapProfiler::FindSnapshot(uid2)); |
| 1450 CHECK_EQ(s3, v8::HeapProfiler::FindSnapshot(uid3)); |
| 1451 s3->Delete(); |
| 1452 CHECK_EQ(0, v8::HeapProfiler::GetSnapshotsCount()); |
| 1453 CHECK_EQ(NULL, v8::HeapProfiler::FindSnapshot(uid3)); |
| 1454 } |
| 1455 |
1398 #endif // ENABLE_LOGGING_AND_PROFILING | 1456 #endif // ENABLE_LOGGING_AND_PROFILING |
OLD | NEW |