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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/v8globals.h ('k') | test/cctest/test-log-stack-tracer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 1306 matching lines...) Expand 10 before | Expand all | Expand 10 after
1317 1317
1318 CHECK_EQ(1, barNode->GetChildrenCount()); 1318 CHECK_EQ(1, barNode->GetChildrenCount());
1319 const v8::CpuProfileNode* nativeNode2 = GetChild(barNode, "CallJsFunction2"); 1319 const v8::CpuProfileNode* nativeNode2 = GetChild(barNode, "CallJsFunction2");
1320 1320
1321 CHECK_EQ(1, nativeNode2->GetChildrenCount()); 1321 CHECK_EQ(1, nativeNode2->GetChildrenCount());
1322 GetChild(nativeNode2, "foo"); 1322 GetChild(nativeNode2, "foo");
1323 1323
1324 v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler(); 1324 v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler();
1325 cpu_profiler->DeleteAllCpuProfiles(); 1325 cpu_profiler->DeleteAllCpuProfiles();
1326 } 1326 }
1327
1328
1329 // [Top down]:
1330 // 6 0 (root) #0 1
1331 // 3 3 (program) #0 2
1332 // 3 3 (idle) #0 3
1333 TEST(IdleTime) {
1334 LocalContext env;
1335 v8::HandleScope scope(env->GetIsolate());
1336 v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler();
1337
1338 v8::Local<v8::String> profile_name = v8::String::New("my_profile");
1339 cpu_profiler->StartCpuProfiling(profile_name);
1340
1341 i::Isolate* isolate = i::Isolate::Current();
1342 i::ProfilerEventsProcessor* processor = isolate->cpu_profiler()->processor();
1343 processor->AddCurrentStack(isolate);
1344
1345 cpu_profiler->SetIdle(true);
1346
1347 for (int i = 0; i < 3; i++) {
1348 processor->AddCurrentStack(isolate);
1349 }
1350
1351 cpu_profiler->SetIdle(false);
1352 processor->AddCurrentStack(isolate);
1353
1354
1355 const v8::CpuProfile* profile = cpu_profiler->StopCpuProfiling(profile_name);
1356 CHECK_NE(NULL, profile);
1357 // Dump collected profile to have a better diagnostic in case of failure.
1358 reinterpret_cast<i::CpuProfile*>(
1359 const_cast<v8::CpuProfile*>(profile))->Print();
1360
1361 const v8::CpuProfileNode* root = profile->GetTopDownRoot();
1362 ScopedVector<v8::Handle<v8::String> > names(3);
1363 names[0] = v8::String::New(ProfileGenerator::kGarbageCollectorEntryName);
1364 names[1] = v8::String::New(ProfileGenerator::kProgramEntryName);
1365 names[2] = v8::String::New(ProfileGenerator::kIdleEntryName);
1366 CheckChildrenNames(root, names);
1367
1368 const v8::CpuProfileNode* programNode =
1369 GetChild(root, ProfileGenerator::kProgramEntryName);
1370 CHECK_EQ(0, programNode->GetChildrenCount());
1371 CHECK_GE(programNode->GetSelfSamplesCount(), 3);
1372
1373 const v8::CpuProfileNode* idleNode =
1374 GetChild(root, ProfileGenerator::kIdleEntryName);
1375 CHECK_EQ(0, idleNode->GetChildrenCount());
1376 CHECK_GE(idleNode->GetSelfSamplesCount(), 3);
1377
1378 cpu_profiler->DeleteAllCpuProfiles();
1379 }
OLDNEW
« 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