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

Side by Side Diff: test/cctest/test-cpu-profiler.cc

Issue 13457002: Isolatify CPU profiler (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 8 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/runtime.cc ('k') | test/cctest/test-profile-generator.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 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 top_down_stub_children->last()->children(); 212 top_down_stub_children->last()->children();
213 CHECK_EQ(0, top_down_ddd_children->length()); 213 CHECK_EQ(0, top_down_ddd_children->length());
214 } 214 }
215 215
216 216
217 // http://crbug/51594 217 // http://crbug/51594
218 // This test must not crash. 218 // This test must not crash.
219 TEST(CrashIfStoppingLastNonExistentProfile) { 219 TEST(CrashIfStoppingLastNonExistentProfile) {
220 InitializeVM(); 220 InitializeVM();
221 TestSetup test_setup; 221 TestSetup test_setup;
222 CpuProfiler::SetUp(); 222 CpuProfiler* profiler = i::Isolate::Current()->cpu_profiler();
223 CpuProfiler::StartProfiling("1"); 223 profiler->StartProfiling("1");
224 CpuProfiler::StopProfiling("2"); 224 profiler->StopProfiling("2");
225 CpuProfiler::StartProfiling("1"); 225 profiler->StartProfiling("1");
226 CpuProfiler::StopProfiling(""); 226 profiler->StopProfiling("");
227 CpuProfiler::TearDown();
228 } 227 }
229 228
230 229
231 // http://code.google.com/p/v8/issues/detail?id=1398 230 // http://code.google.com/p/v8/issues/detail?id=1398
232 // Long stacks (exceeding max frames limit) must not be erased. 231 // Long stacks (exceeding max frames limit) must not be erased.
233 TEST(Issue1398) { 232 TEST(Issue1398) {
234 TestSetup test_setup; 233 TestSetup test_setup;
235 CpuProfilesCollection profiles; 234 CpuProfilesCollection profiles;
236 profiles.StartProfiling("", 1, false); 235 profiles.StartProfiling("", 1, false);
237 ProfileGenerator generator(&profiles); 236 ProfileGenerator generator(&profiles);
(...skipping 26 matching lines...) Expand all
264 ++actual_depth; 263 ++actual_depth;
265 } 264 }
266 265
267 CHECK_EQ(1 + i::TickSample::kMaxFramesCount, actual_depth); // +1 for PC. 266 CHECK_EQ(1 + i::TickSample::kMaxFramesCount, actual_depth); // +1 for PC.
268 } 267 }
269 268
270 269
271 TEST(DeleteAllCpuProfiles) { 270 TEST(DeleteAllCpuProfiles) {
272 InitializeVM(); 271 InitializeVM();
273 TestSetup test_setup; 272 TestSetup test_setup;
274 CpuProfiler::SetUp(); 273 CpuProfiler* profiler = i::Isolate::Current()->cpu_profiler();
275 CHECK_EQ(0, CpuProfiler::GetProfilesCount()); 274 CHECK_EQ(0, profiler->GetProfilesCount());
276 CpuProfiler::DeleteAllProfiles(); 275 profiler->DeleteAllProfiles();
277 CHECK_EQ(0, CpuProfiler::GetProfilesCount()); 276 CHECK_EQ(0, profiler->GetProfilesCount());
278 277
279 CpuProfiler::StartProfiling("1"); 278 profiler->StartProfiling("1");
280 CpuProfiler::StopProfiling("1"); 279 profiler->StopProfiling("1");
281 CHECK_EQ(1, CpuProfiler::GetProfilesCount()); 280 CHECK_EQ(1, profiler->GetProfilesCount());
282 CpuProfiler::DeleteAllProfiles(); 281 profiler->DeleteAllProfiles();
283 CHECK_EQ(0, CpuProfiler::GetProfilesCount()); 282 CHECK_EQ(0, profiler->GetProfilesCount());
284 CpuProfiler::StartProfiling("1"); 283 profiler->StartProfiling("1");
285 CpuProfiler::StartProfiling("2"); 284 profiler->StartProfiling("2");
286 CpuProfiler::StopProfiling("2"); 285 profiler->StopProfiling("2");
287 CpuProfiler::StopProfiling("1"); 286 profiler->StopProfiling("1");
288 CHECK_EQ(2, CpuProfiler::GetProfilesCount()); 287 CHECK_EQ(2, profiler->GetProfilesCount());
289 CpuProfiler::DeleteAllProfiles(); 288 profiler->DeleteAllProfiles();
290 CHECK_EQ(0, CpuProfiler::GetProfilesCount()); 289 CHECK_EQ(0, profiler->GetProfilesCount());
291 290
292 // Test profiling cancellation by the 'delete' command. 291 // Test profiling cancellation by the 'delete' command.
293 CpuProfiler::StartProfiling("1"); 292 profiler->StartProfiling("1");
294 CpuProfiler::StartProfiling("2"); 293 profiler->StartProfiling("2");
295 CHECK_EQ(0, CpuProfiler::GetProfilesCount()); 294 CHECK_EQ(0, profiler->GetProfilesCount());
296 CpuProfiler::DeleteAllProfiles(); 295 profiler->DeleteAllProfiles();
297 CHECK_EQ(0, CpuProfiler::GetProfilesCount()); 296 CHECK_EQ(0, profiler->GetProfilesCount());
298
299 CpuProfiler::TearDown();
300 } 297 }
301 298
302 299
303 TEST(DeleteCpuProfile) { 300 TEST(DeleteCpuProfile) {
304 LocalContext env; 301 LocalContext env;
305 v8::HandleScope scope(env->GetIsolate()); 302 v8::HandleScope scope(env->GetIsolate());
306 303
307 CHECK_EQ(0, v8::CpuProfiler::GetProfilesCount()); 304 CHECK_EQ(0, v8::CpuProfiler::GetProfilesCount());
308 v8::Local<v8::String> name1 = v8::String::New("1"); 305 v8::Local<v8::String> name1 = v8::String::New("1");
309 v8::CpuProfiler::StartProfiling(name1); 306 v8::CpuProfiler::StartProfiling(name1);
310 const v8::CpuProfile* p1 = v8::CpuProfiler::StopProfiling(name1); 307 const v8::CpuProfile* p1 = v8::CpuProfiler::StopProfiling(name1);
311 CHECK_NE(NULL, p1); 308 CHECK_NE(NULL, p1);
312 CHECK_EQ(1, v8::CpuProfiler::GetProfilesCount()); 309 CHECK_EQ(1, v8::CpuProfiler::GetProfilesCount());
313 unsigned uid1 = p1->GetUid(); 310 unsigned uid1 = p1->GetUid();
314 CHECK_EQ(p1, v8::CpuProfiler::FindProfile(uid1)); 311 CHECK_EQ(p1, v8::CpuProfiler::FindProfile(uid1));
315 const_cast<v8::CpuProfile*>(p1)->Delete(); 312 const_cast<v8::CpuProfile*>(p1)->Delete();
316 CHECK_EQ(0, CpuProfiler::GetProfilesCount()); 313 CHECK_EQ(0, v8::CpuProfiler::GetProfilesCount());
317 CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid1)); 314 CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid1));
318 315
319 v8::Local<v8::String> name2 = v8::String::New("2"); 316 v8::Local<v8::String> name2 = v8::String::New("2");
320 v8::CpuProfiler::StartProfiling(name2); 317 v8::CpuProfiler::StartProfiling(name2);
321 const v8::CpuProfile* p2 = v8::CpuProfiler::StopProfiling(name2); 318 const v8::CpuProfile* p2 = v8::CpuProfiler::StopProfiling(name2);
322 CHECK_NE(NULL, p2); 319 CHECK_NE(NULL, p2);
323 CHECK_EQ(1, v8::CpuProfiler::GetProfilesCount()); 320 CHECK_EQ(1, v8::CpuProfiler::GetProfilesCount());
324 unsigned uid2 = p2->GetUid(); 321 unsigned uid2 = p2->GetUid();
325 CHECK_NE(static_cast<int>(uid1), static_cast<int>(uid2)); 322 CHECK_NE(static_cast<int>(uid1), static_cast<int>(uid2));
326 CHECK_EQ(p2, v8::CpuProfiler::FindProfile(uid2)); 323 CHECK_EQ(p2, v8::CpuProfiler::FindProfile(uid2));
327 CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid1)); 324 CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid1));
328 v8::Local<v8::String> name3 = v8::String::New("3"); 325 v8::Local<v8::String> name3 = v8::String::New("3");
329 v8::CpuProfiler::StartProfiling(name3); 326 v8::CpuProfiler::StartProfiling(name3);
330 const v8::CpuProfile* p3 = v8::CpuProfiler::StopProfiling(name3); 327 const v8::CpuProfile* p3 = v8::CpuProfiler::StopProfiling(name3);
331 CHECK_NE(NULL, p3); 328 CHECK_NE(NULL, p3);
332 CHECK_EQ(2, v8::CpuProfiler::GetProfilesCount()); 329 CHECK_EQ(2, v8::CpuProfiler::GetProfilesCount());
333 unsigned uid3 = p3->GetUid(); 330 unsigned uid3 = p3->GetUid();
334 CHECK_NE(static_cast<int>(uid1), static_cast<int>(uid3)); 331 CHECK_NE(static_cast<int>(uid1), static_cast<int>(uid3));
335 CHECK_EQ(p3, v8::CpuProfiler::FindProfile(uid3)); 332 CHECK_EQ(p3, v8::CpuProfiler::FindProfile(uid3));
336 CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid1)); 333 CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid1));
337 const_cast<v8::CpuProfile*>(p2)->Delete(); 334 const_cast<v8::CpuProfile*>(p2)->Delete();
338 CHECK_EQ(1, v8::CpuProfiler::GetProfilesCount()); 335 CHECK_EQ(1, v8::CpuProfiler::GetProfilesCount());
339 CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid2)); 336 CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid2));
340 CHECK_EQ(p3, v8::CpuProfiler::FindProfile(uid3)); 337 CHECK_EQ(p3, v8::CpuProfiler::FindProfile(uid3));
341 const_cast<v8::CpuProfile*>(p3)->Delete(); 338 const_cast<v8::CpuProfile*>(p3)->Delete();
342 CHECK_EQ(0, CpuProfiler::GetProfilesCount()); 339 CHECK_EQ(0, v8::CpuProfiler::GetProfilesCount());
343 CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid3)); 340 CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid3));
344 CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid2)); 341 CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid2));
345 CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid1)); 342 CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid1));
346 } 343 }
347 344
348 345
349 TEST(DeleteCpuProfileDifferentTokens) { 346 TEST(DeleteCpuProfileDifferentTokens) {
350 LocalContext env; 347 LocalContext env;
351 v8::HandleScope scope(env->GetIsolate()); 348 v8::HandleScope scope(env->GetIsolate());
352 349
353 CHECK_EQ(0, v8::CpuProfiler::GetProfilesCount()); 350 CHECK_EQ(0, v8::CpuProfiler::GetProfilesCount());
354 v8::Local<v8::String> name1 = v8::String::New("1"); 351 v8::Local<v8::String> name1 = v8::String::New("1");
355 v8::CpuProfiler::StartProfiling(name1); 352 v8::CpuProfiler::StartProfiling(name1);
356 const v8::CpuProfile* p1 = v8::CpuProfiler::StopProfiling(name1); 353 const v8::CpuProfile* p1 = v8::CpuProfiler::StopProfiling(name1);
357 CHECK_NE(NULL, p1); 354 CHECK_NE(NULL, p1);
358 CHECK_EQ(1, v8::CpuProfiler::GetProfilesCount()); 355 CHECK_EQ(1, v8::CpuProfiler::GetProfilesCount());
359 unsigned uid1 = p1->GetUid(); 356 unsigned uid1 = p1->GetUid();
360 CHECK_EQ(p1, v8::CpuProfiler::FindProfile(uid1)); 357 CHECK_EQ(p1, v8::CpuProfiler::FindProfile(uid1));
361 v8::Local<v8::String> token1 = v8::String::New("token1"); 358 v8::Local<v8::String> token1 = v8::String::New("token1");
362 const v8::CpuProfile* p1_t1 = v8::CpuProfiler::FindProfile(uid1, token1); 359 const v8::CpuProfile* p1_t1 = v8::CpuProfiler::FindProfile(uid1, token1);
363 CHECK_NE(NULL, p1_t1); 360 CHECK_NE(NULL, p1_t1);
364 CHECK_NE(p1, p1_t1); 361 CHECK_NE(p1, p1_t1);
365 CHECK_EQ(1, v8::CpuProfiler::GetProfilesCount()); 362 CHECK_EQ(1, v8::CpuProfiler::GetProfilesCount());
366 const_cast<v8::CpuProfile*>(p1)->Delete(); 363 const_cast<v8::CpuProfile*>(p1)->Delete();
367 CHECK_EQ(0, CpuProfiler::GetProfilesCount()); 364 CHECK_EQ(0, v8::CpuProfiler::GetProfilesCount());
368 CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid1)); 365 CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid1));
369 CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid1, token1)); 366 CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid1, token1));
370 const_cast<v8::CpuProfile*>(p1_t1)->Delete(); 367 const_cast<v8::CpuProfile*>(p1_t1)->Delete();
371 CHECK_EQ(0, CpuProfiler::GetProfilesCount()); 368 CHECK_EQ(0, v8::CpuProfiler::GetProfilesCount());
372 369
373 v8::Local<v8::String> name2 = v8::String::New("2"); 370 v8::Local<v8::String> name2 = v8::String::New("2");
374 v8::CpuProfiler::StartProfiling(name2); 371 v8::CpuProfiler::StartProfiling(name2);
375 v8::Local<v8::String> token2 = v8::String::New("token2"); 372 v8::Local<v8::String> token2 = v8::String::New("token2");
376 const v8::CpuProfile* p2_t2 = v8::CpuProfiler::StopProfiling(name2, token2); 373 const v8::CpuProfile* p2_t2 = v8::CpuProfiler::StopProfiling(name2, token2);
377 CHECK_NE(NULL, p2_t2); 374 CHECK_NE(NULL, p2_t2);
378 CHECK_EQ(1, v8::CpuProfiler::GetProfilesCount()); 375 CHECK_EQ(1, v8::CpuProfiler::GetProfilesCount());
379 unsigned uid2 = p2_t2->GetUid(); 376 unsigned uid2 = p2_t2->GetUid();
380 CHECK_NE(static_cast<int>(uid1), static_cast<int>(uid2)); 377 CHECK_NE(static_cast<int>(uid1), static_cast<int>(uid2));
381 const v8::CpuProfile* p2 = v8::CpuProfiler::FindProfile(uid2); 378 const v8::CpuProfile* p2 = v8::CpuProfiler::FindProfile(uid2);
382 CHECK_NE(p2_t2, p2); 379 CHECK_NE(p2_t2, p2);
383 v8::Local<v8::String> name3 = v8::String::New("3"); 380 v8::Local<v8::String> name3 = v8::String::New("3");
384 v8::CpuProfiler::StartProfiling(name3); 381 v8::CpuProfiler::StartProfiling(name3);
385 const v8::CpuProfile* p3 = v8::CpuProfiler::StopProfiling(name3); 382 const v8::CpuProfile* p3 = v8::CpuProfiler::StopProfiling(name3);
386 CHECK_NE(NULL, p3); 383 CHECK_NE(NULL, p3);
387 CHECK_EQ(2, v8::CpuProfiler::GetProfilesCount()); 384 CHECK_EQ(2, v8::CpuProfiler::GetProfilesCount());
388 unsigned uid3 = p3->GetUid(); 385 unsigned uid3 = p3->GetUid();
389 CHECK_NE(static_cast<int>(uid1), static_cast<int>(uid3)); 386 CHECK_NE(static_cast<int>(uid1), static_cast<int>(uid3));
390 CHECK_EQ(p3, v8::CpuProfiler::FindProfile(uid3)); 387 CHECK_EQ(p3, v8::CpuProfiler::FindProfile(uid3));
391 const_cast<v8::CpuProfile*>(p2_t2)->Delete(); 388 const_cast<v8::CpuProfile*>(p2_t2)->Delete();
392 CHECK_EQ(1, v8::CpuProfiler::GetProfilesCount()); 389 CHECK_EQ(1, v8::CpuProfiler::GetProfilesCount());
393 CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid2)); 390 CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid2));
394 CHECK_EQ(p3, v8::CpuProfiler::FindProfile(uid3)); 391 CHECK_EQ(p3, v8::CpuProfiler::FindProfile(uid3));
395 const_cast<v8::CpuProfile*>(p2)->Delete(); 392 const_cast<v8::CpuProfile*>(p2)->Delete();
396 CHECK_EQ(1, v8::CpuProfiler::GetProfilesCount()); 393 CHECK_EQ(1, v8::CpuProfiler::GetProfilesCount());
397 CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid2)); 394 CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid2));
398 CHECK_EQ(p3, v8::CpuProfiler::FindProfile(uid3)); 395 CHECK_EQ(p3, v8::CpuProfiler::FindProfile(uid3));
399 const_cast<v8::CpuProfile*>(p3)->Delete(); 396 const_cast<v8::CpuProfile*>(p3)->Delete();
400 CHECK_EQ(0, CpuProfiler::GetProfilesCount()); 397 CHECK_EQ(0, v8::CpuProfiler::GetProfilesCount());
401 CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid3)); 398 CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid3));
402 } 399 }
OLDNEW
« no previous file with comments | « src/runtime.cc ('k') | test/cctest/test-profile-generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698