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

Unified Diff: test/cctest/test-profile-generator.cc

Issue 17642009: CPUProfiler: propagate scriptId to the front-end (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: completely reworked Created 7 years, 6 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
« no previous file with comments | « src/profile-generator-inl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-profile-generator.cc
diff --git a/test/cctest/test-profile-generator.cc b/test/cctest/test-profile-generator.cc
index e9197896734da11548615e2424bafff2608e494f..97d63a75be719149d87982a54ff797e30607de8a 100644
--- a/test/cctest/test-profile-generator.cc
+++ b/test/cctest/test-profile-generator.cc
@@ -905,3 +905,53 @@ TEST(Issue51919) {
for (int i = 0; i < CpuProfilesCollection::kMaxSimultaneousProfiles; ++i)
i::DeleteArray(titles[i]);
}
+
+
+TEST(ProfileNodeScriptId) {
+ // This test does not pass with inlining enabled since inlined functions
+ // don't appear in the stack trace.
yurys 2013/07/01 14:50:00 I think we should be testing with inlining on as w
+ i::FLAG_use_inlining = false;
+
+ v8::Isolate* isolate = v8::Isolate::GetCurrent();
+ v8::HandleScope scope(isolate);
+ const char* extensions[] = { "v8/profiler" };
+ v8::ExtensionConfiguration config(1, extensions);
+ v8::Local<v8::Context> context = v8::Context::New(isolate, &config);
+ context->Enter();
yurys 2013/07/01 14:50:00 Please use LocalContext env(config); instead, it w
+
+ CpuProfiler* profiler = i::Isolate::Current()->cpu_profiler();
+ CHECK_EQ(0, profiler->GetProfilesCount());
+ v8::Handle<v8::Script> script_a = v8::Script::Compile(v8::String::New(
+ "function a() { startProfiling(); }\n"));
+ script_a->Run();
+ v8::Handle<v8::Script> script_b = v8::Script::Compile(v8::String::New(
+ "function b() { a(); }\n"
+ "b();\n"
+ "stopProfiling();\n"));
+ script_b->Run();
+ CHECK_EQ(1, profiler->GetProfilesCount());
+ CpuProfile* profile = profiler->GetProfile(NULL, 0);
yurys 2013/07/01 14:50:00 Why don't we use public API here?
+ const ProfileTree* topDown = profile->top_down();
+ const ProfileNode* current = topDown->root();
+ const_cast<ProfileNode*>(current)->Print(0);
+ // The tree should look like this:
+ // (root)
+ // (anonymous function)
+ // b
+ // a
+ // There can also be:
+ // startProfiling
+ // if the sampler managed to get a tick.
+ current = PickChild(current, "(anonymous function)");
yurys 2013/07/01 14:50:00 Please use i::ProfilerGenerator::kAnonymousFunctio
+ CHECK_NE(NULL, const_cast<ProfileNode*>(current));
+
+ current = PickChild(current, "b");
+ CHECK_NE(NULL, const_cast<ProfileNode*>(current));
+ CHECK_EQ(script_b->GetId(), current->entry()->script_id());
+
+ current = PickChild(current, "a");
+ CHECK_NE(NULL, const_cast<ProfileNode*>(current));
+ CHECK_EQ(script_a->GetId(), current->entry()->script_id());
+}
+
+
« no previous file with comments | « src/profile-generator-inl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698