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

Unified Diff: test/cctest/test-cpu-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
Index: test/cctest/test-cpu-profiler.cc
diff --git a/test/cctest/test-cpu-profiler.cc b/test/cctest/test-cpu-profiler.cc
index 507f23682e574a4263edb247aa62847db47e62ab..c65364d04c666aa79fc003ddf644ec5da49bd2b0 100644
--- a/test/cctest/test-cpu-profiler.cc
+++ b/test/cctest/test-cpu-profiler.cc
@@ -7,6 +7,7 @@
#include "v8.h"
#include "cpu-profiler-inl.h"
#include "cctest.h"
+#include "../include/v8-profiler.h"
namespace i = v8::internal;
@@ -236,4 +237,134 @@ TEST(CrashIfStoppingLastNonExistentProfile) {
CpuProfiler::TearDown();
}
+
+TEST(DeleteAllCpuProfiles) {
+ InitializeVM();
+ TestSetup test_setup;
+ CpuProfiler::Setup();
+ CHECK_EQ(0, CpuProfiler::GetProfilesCount());
+ CpuProfiler::DeleteAllProfiles();
+ CHECK_EQ(0, CpuProfiler::GetProfilesCount());
+
+ CpuProfiler::StartProfiling("1");
+ CpuProfiler::StopProfiling("1");
+ CHECK_EQ(1, CpuProfiler::GetProfilesCount());
+ CpuProfiler::DeleteAllProfiles();
+ CHECK_EQ(0, CpuProfiler::GetProfilesCount());
+ CpuProfiler::StartProfiling("1");
+ CpuProfiler::StartProfiling("2");
+ CpuProfiler::StopProfiling("2");
+ CpuProfiler::StopProfiling("1");
+ CHECK_EQ(2, CpuProfiler::GetProfilesCount());
+ CpuProfiler::DeleteAllProfiles();
+ CHECK_EQ(0, CpuProfiler::GetProfilesCount());
+
+ // Test profiling cancellation by the 'delete' command.
+ CpuProfiler::StartProfiling("1");
+ CpuProfiler::StartProfiling("2");
+ CHECK_EQ(0, CpuProfiler::GetProfilesCount());
+ CpuProfiler::DeleteAllProfiles();
+ CHECK_EQ(0, CpuProfiler::GetProfilesCount());
+
+ CpuProfiler::TearDown();
+}
+
+
+TEST(DeleteCpuProfile) {
+ v8::HandleScope scope;
+ LocalContext env;
+
+ CHECK_EQ(0, v8::CpuProfiler::GetProfilesCount());
+ v8::Local<v8::String> name1 = v8::String::New("1");
+ v8::CpuProfiler::StartProfiling(name1);
+ const v8::CpuProfile* p1 = v8::CpuProfiler::StopProfiling(name1);
+ CHECK_NE(NULL, p1);
+ CHECK_EQ(1, v8::CpuProfiler::GetProfilesCount());
+ unsigned uid1 = p1->GetUid();
+ CHECK_EQ(p1, v8::CpuProfiler::FindProfile(uid1));
+ p1->Delete();
+ CHECK_EQ(0, CpuProfiler::GetProfilesCount());
+ CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid1));
Vitaly Repeshko 2011/03/22 14:30:36 It'd be nice to test this again later to make sure
mnaganov (inactive) 2011/03/22 16:03:09 Added a couple of times more after.
+
+ v8::Local<v8::String> name2 = v8::String::New("2");
+ v8::CpuProfiler::StartProfiling(name2);
+ const v8::CpuProfile* p2 = v8::CpuProfiler::StopProfiling(name2);
+ CHECK_NE(NULL, p2);
+ CHECK_EQ(1, v8::CpuProfiler::GetProfilesCount());
+ unsigned uid2 = p2->GetUid();
+ CHECK_NE(static_cast<int>(uid1), static_cast<int>(uid2));
+ CHECK_EQ(p2, v8::CpuProfiler::FindProfile(uid2));
+ v8::Local<v8::String> name3 = v8::String::New("3");
+ v8::CpuProfiler::StartProfiling(name3);
+ const v8::CpuProfile* p3 = v8::CpuProfiler::StopProfiling(name3);
+ CHECK_NE(NULL, p3);
+ CHECK_EQ(2, v8::CpuProfiler::GetProfilesCount());
+ unsigned uid3 = p3->GetUid();
+ CHECK_NE(static_cast<int>(uid1), static_cast<int>(uid3));
+ CHECK_EQ(p3, v8::CpuProfiler::FindProfile(uid3));
+ p2->Delete();
+ CHECK_EQ(1, v8::CpuProfiler::GetProfilesCount());
+ CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid2));
Vitaly Repeshko 2011/03/22 14:30:36 Same here.
mnaganov (inactive) 2011/03/22 16:03:09 Done.
+ CHECK_EQ(p3, v8::CpuProfiler::FindProfile(uid3));
+ p3->Delete();
+ CHECK_EQ(0, CpuProfiler::GetProfilesCount());
+ CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid3));
+}
+
+
+TEST(DeleteCpuProfileDifferentTokens) {
+ v8::HandleScope scope;
+ LocalContext env;
+
+ CHECK_EQ(0, v8::CpuProfiler::GetProfilesCount());
+ v8::Local<v8::String> name1 = v8::String::New("1");
+ v8::CpuProfiler::StartProfiling(name1);
+ const v8::CpuProfile* p1 = v8::CpuProfiler::StopProfiling(name1);
+ CHECK_NE(NULL, p1);
+ CHECK_EQ(1, v8::CpuProfiler::GetProfilesCount());
+ unsigned uid1 = p1->GetUid();
+ CHECK_EQ(p1, v8::CpuProfiler::FindProfile(uid1));
+ v8::Local<v8::String> token1 = v8::String::New("token1");
+ const v8::CpuProfile* p1_t1 = v8::CpuProfiler::FindProfile(uid1, token1);
+ CHECK_NE(NULL, p1_t1);
+ CHECK_NE(p1, p1_t1);
+ CHECK_EQ(1, v8::CpuProfiler::GetProfilesCount());
+ p1->Delete();
+ CHECK_EQ(0, CpuProfiler::GetProfilesCount());
+ CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid1));
+ CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid1, token1));
+ p1_t1->Delete();
+ CHECK_EQ(0, CpuProfiler::GetProfilesCount());
+
+ v8::Local<v8::String> name2 = v8::String::New("2");
+ v8::CpuProfiler::StartProfiling(name2);
+ v8::Local<v8::String> token2 = v8::String::New("token2");
+ const v8::CpuProfile* p2_t2 = v8::CpuProfiler::StopProfiling(name2, token2);
+ CHECK_NE(NULL, p2_t2);
+ CHECK_EQ(1, v8::CpuProfiler::GetProfilesCount());
+ unsigned uid2 = p2_t2->GetUid();
+ CHECK_NE(static_cast<int>(uid1), static_cast<int>(uid2));
+ const v8::CpuProfile* p2 = v8::CpuProfiler::FindProfile(uid2);
+ CHECK_NE(p2_t2, p2);
+ v8::Local<v8::String> name3 = v8::String::New("3");
+ v8::CpuProfiler::StartProfiling(name3);
+ const v8::CpuProfile* p3 = v8::CpuProfiler::StopProfiling(name3);
+ CHECK_NE(NULL, p3);
+ CHECK_EQ(2, v8::CpuProfiler::GetProfilesCount());
+ unsigned uid3 = p3->GetUid();
+ CHECK_NE(static_cast<int>(uid1), static_cast<int>(uid3));
+ CHECK_EQ(p3, v8::CpuProfiler::FindProfile(uid3));
+ p2_t2->Delete();
+ CHECK_EQ(1, v8::CpuProfiler::GetProfilesCount());
+ CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid2));
+ CHECK_EQ(p3, v8::CpuProfiler::FindProfile(uid3));
+ p2->Delete();
+ CHECK_EQ(1, v8::CpuProfiler::GetProfilesCount());
+ CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid2));
+ CHECK_EQ(p3, v8::CpuProfiler::FindProfile(uid3));
+ p3->Delete();
+ CHECK_EQ(0, CpuProfiler::GetProfilesCount());
+ CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid3));
+}
+
#endif // ENABLE_LOGGING_AND_PROFILING

Powered by Google App Engine
This is Rietveld 408576698