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

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

Issue 6685084: Add support for CPU and heap profiles deletion. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Implemente per-profile deletion Created 9 years, 9 months 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
« test/cctest/test-cpu-profiler.cc ('K') | « test/cctest/test-cpu-profiler.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-profiler.cc
diff --git a/test/cctest/test-heap-profiler.cc b/test/cctest/test-heap-profiler.cc
index bda97a4a38d73cafb51b25f51527c8c88fca7389..506a4ff7f7e29e5fd91daa458a1ae3e38b728ed4 100644
--- a/test/cctest/test-heap-profiler.cc
+++ b/test/cctest/test-heap-profiler.cc
@@ -1395,4 +1395,62 @@ TEST(HeapSnapshotRetainedObjectInfo) {
CHECK_EQ(ccc, GetProperty(n_CCC, v8::HeapGraphEdge::kInternal, "Native"));
}
+
+TEST(DeleteAllHeapSnapshots) {
+ v8::HandleScope scope;
+ LocalContext env;
+
+ CHECK_EQ(0, v8::HeapProfiler::GetSnapshotsCount());
+ v8::HeapProfiler::DeleteAllSnapshots();
+ CHECK_EQ(0, v8::HeapProfiler::GetSnapshotsCount());
+ CHECK_NE(NULL, v8::HeapProfiler::TakeSnapshot(v8::String::New("1")));
+ CHECK_EQ(1, v8::HeapProfiler::GetSnapshotsCount());
+ v8::HeapProfiler::DeleteAllSnapshots();
+ CHECK_EQ(0, v8::HeapProfiler::GetSnapshotsCount());
+ CHECK_NE(NULL, v8::HeapProfiler::TakeSnapshot(v8::String::New("1")));
+ CHECK_NE(NULL, v8::HeapProfiler::TakeSnapshot(v8::String::New("2")));
+ CHECK_EQ(2, v8::HeapProfiler::GetSnapshotsCount());
+ v8::HeapProfiler::DeleteAllSnapshots();
+ CHECK_EQ(0, v8::HeapProfiler::GetSnapshotsCount());
+}
+
+
+TEST(DeleteHeapSnapshot) {
+ v8::HandleScope scope;
+ LocalContext env;
+
+ CHECK_EQ(0, v8::HeapProfiler::GetSnapshotsCount());
+ const v8::HeapSnapshot* s1 =
+ v8::HeapProfiler::TakeSnapshot(v8::String::New("1"));
+ CHECK_NE(NULL, s1);
+ CHECK_EQ(1, v8::HeapProfiler::GetSnapshotsCount());
+ unsigned uid1 = s1->GetUid();
+ CHECK_EQ(s1, v8::HeapProfiler::FindSnapshot(uid1));
+ s1->Delete();
+ CHECK_EQ(0, v8::HeapProfiler::GetSnapshotsCount());
+ CHECK_EQ(NULL, v8::HeapProfiler::FindSnapshot(uid1));
+
+ const v8::HeapSnapshot* s2 =
+ v8::HeapProfiler::TakeSnapshot(v8::String::New("2"));
+ CHECK_NE(NULL, s2);
+ CHECK_EQ(1, v8::HeapProfiler::GetSnapshotsCount());
+ unsigned uid2 = s2->GetUid();
+ CHECK_NE(static_cast<int>(uid1), static_cast<int>(uid2));
+ CHECK_EQ(s2, v8::HeapProfiler::FindSnapshot(uid2));
+ const v8::HeapSnapshot* s3 =
+ v8::HeapProfiler::TakeSnapshot(v8::String::New("3"));
+ CHECK_NE(NULL, s3);
+ CHECK_EQ(2, v8::HeapProfiler::GetSnapshotsCount());
+ unsigned uid3 = s3->GetUid();
+ CHECK_NE(static_cast<int>(uid1), static_cast<int>(uid3));
+ CHECK_EQ(s3, v8::HeapProfiler::FindSnapshot(uid3));
+ s2->Delete();
+ CHECK_EQ(1, v8::HeapProfiler::GetSnapshotsCount());
+ CHECK_EQ(NULL, v8::HeapProfiler::FindSnapshot(uid2));
+ CHECK_EQ(s3, v8::HeapProfiler::FindSnapshot(uid3));
+ s3->Delete();
+ CHECK_EQ(0, v8::HeapProfiler::GetSnapshotsCount());
+ CHECK_EQ(NULL, v8::HeapProfiler::FindSnapshot(uid3));
+}
+
#endif // ENABLE_LOGGING_AND_PROFILING
« test/cctest/test-cpu-profiler.cc ('K') | « test/cctest/test-cpu-profiler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698