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

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

Issue 22412003: Support idle time in CPU profiler (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Comment addressed Created 7 years, 4 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/v8globals.h ('k') | test/cctest/test-log-stack-tracer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-cpu-profiler.cc
diff --git a/test/cctest/test-cpu-profiler.cc b/test/cctest/test-cpu-profiler.cc
index daf8db615142001fcebab78e6103e5137f427179..2c3f3edad418c41f259c99813aec96679439241f 100644
--- a/test/cctest/test-cpu-profiler.cc
+++ b/test/cctest/test-cpu-profiler.cc
@@ -1324,3 +1324,56 @@ TEST(JsNative1JsNative2JsSample) {
v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler();
cpu_profiler->DeleteAllCpuProfiles();
}
+
+
+// [Top down]:
+// 6 0 (root) #0 1
+// 3 3 (program) #0 2
+// 3 3 (idle) #0 3
+TEST(IdleTime) {
+ LocalContext env;
+ v8::HandleScope scope(env->GetIsolate());
+ v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler();
+
+ v8::Local<v8::String> profile_name = v8::String::New("my_profile");
+ cpu_profiler->StartCpuProfiling(profile_name);
+
+ i::Isolate* isolate = i::Isolate::Current();
+ i::ProfilerEventsProcessor* processor = isolate->cpu_profiler()->processor();
+ processor->AddCurrentStack(isolate);
+
+ cpu_profiler->SetIdle(true);
+
+ for (int i = 0; i < 3; i++) {
+ processor->AddCurrentStack(isolate);
+ }
+
+ cpu_profiler->SetIdle(false);
+ processor->AddCurrentStack(isolate);
+
+
+ const v8::CpuProfile* profile = cpu_profiler->StopCpuProfiling(profile_name);
+ CHECK_NE(NULL, profile);
+ // Dump collected profile to have a better diagnostic in case of failure.
+ reinterpret_cast<i::CpuProfile*>(
+ const_cast<v8::CpuProfile*>(profile))->Print();
+
+ const v8::CpuProfileNode* root = profile->GetTopDownRoot();
+ ScopedVector<v8::Handle<v8::String> > names(3);
+ names[0] = v8::String::New(ProfileGenerator::kGarbageCollectorEntryName);
+ names[1] = v8::String::New(ProfileGenerator::kProgramEntryName);
+ names[2] = v8::String::New(ProfileGenerator::kIdleEntryName);
+ CheckChildrenNames(root, names);
+
+ const v8::CpuProfileNode* programNode =
+ GetChild(root, ProfileGenerator::kProgramEntryName);
+ CHECK_EQ(0, programNode->GetChildrenCount());
+ CHECK_GE(programNode->GetSelfSamplesCount(), 3);
+
+ const v8::CpuProfileNode* idleNode =
+ GetChild(root, ProfileGenerator::kIdleEntryName);
+ CHECK_EQ(0, idleNode->GetChildrenCount());
+ CHECK_GE(idleNode->GetSelfSamplesCount(), 3);
+
+ cpu_profiler->DeleteAllCpuProfiles();
+}
« no previous file with comments | « src/v8globals.h ('k') | test/cctest/test-log-stack-tracer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698