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 1175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1186 | 1186 |
1187 const v8::HeapSnapshot* snapshot = | 1187 const v8::HeapSnapshot* snapshot = |
1188 v8::HeapProfiler::TakeSnapshot( | 1188 v8::HeapProfiler::TakeSnapshot( |
1189 v8::String::New("agg"), v8::HeapSnapshot::kAggregated); | 1189 v8::String::New("agg"), v8::HeapSnapshot::kAggregated); |
1190 TestJSONStream stream; | 1190 TestJSONStream stream; |
1191 snapshot->Serialize(&stream, v8::HeapSnapshot::kJSON); | 1191 snapshot->Serialize(&stream, v8::HeapSnapshot::kJSON); |
1192 CHECK_GT(stream.size(), 0); | 1192 CHECK_GT(stream.size(), 0); |
1193 CHECK_EQ(1, stream.eos_signaled()); | 1193 CHECK_EQ(1, stream.eos_signaled()); |
1194 } | 1194 } |
1195 | 1195 |
| 1196 |
| 1197 TEST(HeapSnapshotGetNodeById) { |
| 1198 v8::HandleScope scope; |
| 1199 LocalContext env; |
| 1200 |
| 1201 const v8::HeapSnapshot* snapshot = |
| 1202 v8::HeapProfiler::TakeSnapshot(v8::String::New("id")); |
| 1203 const v8::HeapGraphNode* root = snapshot->GetRoot(); |
| 1204 CHECK_EQ(root, snapshot->GetNodeById(root->GetId())); |
| 1205 for (int i = 0, count = root->GetChildrenCount(); i < count; ++i) { |
| 1206 const v8::HeapGraphEdge* prop = root->GetChild(i); |
| 1207 CHECK_EQ( |
| 1208 prop->GetToNode(), snapshot->GetNodeById(prop->GetToNode()->GetId())); |
| 1209 } |
| 1210 // Check a big id, which should not exist yet. |
| 1211 CHECK_EQ(NULL, snapshot->GetNodeById(0x1000000UL)); |
| 1212 } |
| 1213 |
1196 #endif // ENABLE_LOGGING_AND_PROFILING | 1214 #endif // ENABLE_LOGGING_AND_PROFILING |
OLD | NEW |