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

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

Issue 13460002: Isolatify CPU profiler public API (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebase 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/log.h ('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 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 profiler->StartProfiling("2"); 293 profiler->StartProfiling("2");
294 CHECK_EQ(0, profiler->GetProfilesCount()); 294 CHECK_EQ(0, profiler->GetProfilesCount());
295 profiler->DeleteAllProfiles(); 295 profiler->DeleteAllProfiles();
296 CHECK_EQ(0, profiler->GetProfilesCount()); 296 CHECK_EQ(0, profiler->GetProfilesCount());
297 } 297 }
298 298
299 299
300 TEST(DeleteCpuProfile) { 300 TEST(DeleteCpuProfile) {
301 LocalContext env; 301 LocalContext env;
302 v8::HandleScope scope(env->GetIsolate()); 302 v8::HandleScope scope(env->GetIsolate());
303 v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler();
303 304
304 CHECK_EQ(0, v8::CpuProfiler::GetProfilesCount()); 305 CHECK_EQ(0, cpu_profiler->GetProfileCount());
305 v8::Local<v8::String> name1 = v8::String::New("1"); 306 v8::Local<v8::String> name1 = v8::String::New("1");
306 v8::CpuProfiler::StartProfiling(name1); 307 cpu_profiler->StartCpuProfiling(name1);
307 const v8::CpuProfile* p1 = v8::CpuProfiler::StopProfiling(name1); 308 const v8::CpuProfile* p1 = cpu_profiler->StopCpuProfiling(name1);
308 CHECK_NE(NULL, p1); 309 CHECK_NE(NULL, p1);
309 CHECK_EQ(1, v8::CpuProfiler::GetProfilesCount()); 310 CHECK_EQ(1, cpu_profiler->GetProfileCount());
310 unsigned uid1 = p1->GetUid(); 311 unsigned uid1 = p1->GetUid();
311 CHECK_EQ(p1, v8::CpuProfiler::FindProfile(uid1)); 312 CHECK_EQ(p1, cpu_profiler->FindCpuProfile(uid1));
312 const_cast<v8::CpuProfile*>(p1)->Delete(); 313 const_cast<v8::CpuProfile*>(p1)->Delete();
313 CHECK_EQ(0, v8::CpuProfiler::GetProfilesCount()); 314 CHECK_EQ(0, cpu_profiler->GetProfileCount());
314 CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid1)); 315 CHECK_EQ(NULL, cpu_profiler->FindCpuProfile(uid1));
315 316
316 v8::Local<v8::String> name2 = v8::String::New("2"); 317 v8::Local<v8::String> name2 = v8::String::New("2");
317 v8::CpuProfiler::StartProfiling(name2); 318 cpu_profiler->StartCpuProfiling(name2);
318 const v8::CpuProfile* p2 = v8::CpuProfiler::StopProfiling(name2); 319 const v8::CpuProfile* p2 = cpu_profiler->StopCpuProfiling(name2);
319 CHECK_NE(NULL, p2); 320 CHECK_NE(NULL, p2);
320 CHECK_EQ(1, v8::CpuProfiler::GetProfilesCount()); 321 CHECK_EQ(1, cpu_profiler->GetProfileCount());
321 unsigned uid2 = p2->GetUid(); 322 unsigned uid2 = p2->GetUid();
322 CHECK_NE(static_cast<int>(uid1), static_cast<int>(uid2)); 323 CHECK_NE(static_cast<int>(uid1), static_cast<int>(uid2));
323 CHECK_EQ(p2, v8::CpuProfiler::FindProfile(uid2)); 324 CHECK_EQ(p2, cpu_profiler->FindCpuProfile(uid2));
324 CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid1)); 325 CHECK_EQ(NULL, cpu_profiler->FindCpuProfile(uid1));
325 v8::Local<v8::String> name3 = v8::String::New("3"); 326 v8::Local<v8::String> name3 = v8::String::New("3");
326 v8::CpuProfiler::StartProfiling(name3); 327 cpu_profiler->StartCpuProfiling(name3);
327 const v8::CpuProfile* p3 = v8::CpuProfiler::StopProfiling(name3); 328 const v8::CpuProfile* p3 = cpu_profiler->StopCpuProfiling(name3);
328 CHECK_NE(NULL, p3); 329 CHECK_NE(NULL, p3);
329 CHECK_EQ(2, v8::CpuProfiler::GetProfilesCount()); 330 CHECK_EQ(2, cpu_profiler->GetProfileCount());
330 unsigned uid3 = p3->GetUid(); 331 unsigned uid3 = p3->GetUid();
331 CHECK_NE(static_cast<int>(uid1), static_cast<int>(uid3)); 332 CHECK_NE(static_cast<int>(uid1), static_cast<int>(uid3));
332 CHECK_EQ(p3, v8::CpuProfiler::FindProfile(uid3)); 333 CHECK_EQ(p3, cpu_profiler->FindCpuProfile(uid3));
333 CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid1)); 334 CHECK_EQ(NULL, cpu_profiler->FindCpuProfile(uid1));
334 const_cast<v8::CpuProfile*>(p2)->Delete(); 335 const_cast<v8::CpuProfile*>(p2)->Delete();
335 CHECK_EQ(1, v8::CpuProfiler::GetProfilesCount()); 336 CHECK_EQ(1, cpu_profiler->GetProfileCount());
336 CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid2)); 337 CHECK_EQ(NULL, cpu_profiler->FindCpuProfile(uid2));
337 CHECK_EQ(p3, v8::CpuProfiler::FindProfile(uid3)); 338 CHECK_EQ(p3, cpu_profiler->FindCpuProfile(uid3));
338 const_cast<v8::CpuProfile*>(p3)->Delete(); 339 const_cast<v8::CpuProfile*>(p3)->Delete();
339 CHECK_EQ(0, v8::CpuProfiler::GetProfilesCount()); 340 CHECK_EQ(0, cpu_profiler->GetProfileCount());
340 CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid3)); 341 CHECK_EQ(NULL, cpu_profiler->FindCpuProfile(uid3));
341 CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid2)); 342 CHECK_EQ(NULL, cpu_profiler->FindCpuProfile(uid2));
342 CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid1)); 343 CHECK_EQ(NULL, cpu_profiler->FindCpuProfile(uid1));
343 } 344 }
344 345
345 346
346 TEST(DeleteCpuProfileDifferentTokens) { 347 TEST(DeleteCpuProfileDifferentTokens) {
347 LocalContext env; 348 LocalContext env;
348 v8::HandleScope scope(env->GetIsolate()); 349 v8::HandleScope scope(env->GetIsolate());
350 v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler();
349 351
350 CHECK_EQ(0, v8::CpuProfiler::GetProfilesCount()); 352 CHECK_EQ(0, cpu_profiler->GetProfileCount());
351 v8::Local<v8::String> name1 = v8::String::New("1"); 353 v8::Local<v8::String> name1 = v8::String::New("1");
352 v8::CpuProfiler::StartProfiling(name1); 354 cpu_profiler->StartCpuProfiling(name1);
353 const v8::CpuProfile* p1 = v8::CpuProfiler::StopProfiling(name1); 355 const v8::CpuProfile* p1 = cpu_profiler->StopCpuProfiling(name1);
354 CHECK_NE(NULL, p1); 356 CHECK_NE(NULL, p1);
355 CHECK_EQ(1, v8::CpuProfiler::GetProfilesCount()); 357 CHECK_EQ(1, cpu_profiler->GetProfileCount());
356 unsigned uid1 = p1->GetUid(); 358 unsigned uid1 = p1->GetUid();
357 CHECK_EQ(p1, v8::CpuProfiler::FindProfile(uid1)); 359 CHECK_EQ(p1, cpu_profiler->FindCpuProfile(uid1));
358 v8::Local<v8::String> token1 = v8::String::New("token1"); 360 v8::Local<v8::String> token1 = v8::String::New("token1");
359 const v8::CpuProfile* p1_t1 = v8::CpuProfiler::FindProfile(uid1, token1); 361 const v8::CpuProfile* p1_t1 = cpu_profiler->FindCpuProfile(uid1, token1);
360 CHECK_NE(NULL, p1_t1); 362 CHECK_NE(NULL, p1_t1);
361 CHECK_NE(p1, p1_t1); 363 CHECK_NE(p1, p1_t1);
362 CHECK_EQ(1, v8::CpuProfiler::GetProfilesCount()); 364 CHECK_EQ(1, cpu_profiler->GetProfileCount());
363 const_cast<v8::CpuProfile*>(p1)->Delete(); 365 const_cast<v8::CpuProfile*>(p1)->Delete();
364 CHECK_EQ(0, v8::CpuProfiler::GetProfilesCount()); 366 CHECK_EQ(0, cpu_profiler->GetProfileCount());
365 CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid1)); 367 CHECK_EQ(NULL, cpu_profiler->FindCpuProfile(uid1));
366 CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid1, token1)); 368 CHECK_EQ(NULL, cpu_profiler->FindCpuProfile(uid1, token1));
367 const_cast<v8::CpuProfile*>(p1_t1)->Delete(); 369 const_cast<v8::CpuProfile*>(p1_t1)->Delete();
368 CHECK_EQ(0, v8::CpuProfiler::GetProfilesCount()); 370 CHECK_EQ(0, cpu_profiler->GetProfileCount());
369 371
370 v8::Local<v8::String> name2 = v8::String::New("2"); 372 v8::Local<v8::String> name2 = v8::String::New("2");
371 v8::CpuProfiler::StartProfiling(name2); 373 cpu_profiler->StartCpuProfiling(name2);
372 v8::Local<v8::String> token2 = v8::String::New("token2"); 374 v8::Local<v8::String> token2 = v8::String::New("token2");
373 const v8::CpuProfile* p2_t2 = v8::CpuProfiler::StopProfiling(name2, token2); 375 const v8::CpuProfile* p2_t2 = cpu_profiler->StopCpuProfiling(name2, token2);
374 CHECK_NE(NULL, p2_t2); 376 CHECK_NE(NULL, p2_t2);
375 CHECK_EQ(1, v8::CpuProfiler::GetProfilesCount()); 377 CHECK_EQ(1, cpu_profiler->GetProfileCount());
376 unsigned uid2 = p2_t2->GetUid(); 378 unsigned uid2 = p2_t2->GetUid();
377 CHECK_NE(static_cast<int>(uid1), static_cast<int>(uid2)); 379 CHECK_NE(static_cast<int>(uid1), static_cast<int>(uid2));
378 const v8::CpuProfile* p2 = v8::CpuProfiler::FindProfile(uid2); 380 const v8::CpuProfile* p2 = cpu_profiler->FindCpuProfile(uid2);
379 CHECK_NE(p2_t2, p2); 381 CHECK_NE(p2_t2, p2);
380 v8::Local<v8::String> name3 = v8::String::New("3"); 382 v8::Local<v8::String> name3 = v8::String::New("3");
381 v8::CpuProfiler::StartProfiling(name3); 383 cpu_profiler->StartCpuProfiling(name3);
382 const v8::CpuProfile* p3 = v8::CpuProfiler::StopProfiling(name3); 384 const v8::CpuProfile* p3 = cpu_profiler->StopCpuProfiling(name3);
383 CHECK_NE(NULL, p3); 385 CHECK_NE(NULL, p3);
384 CHECK_EQ(2, v8::CpuProfiler::GetProfilesCount()); 386 CHECK_EQ(2, cpu_profiler->GetProfileCount());
385 unsigned uid3 = p3->GetUid(); 387 unsigned uid3 = p3->GetUid();
386 CHECK_NE(static_cast<int>(uid1), static_cast<int>(uid3)); 388 CHECK_NE(static_cast<int>(uid1), static_cast<int>(uid3));
387 CHECK_EQ(p3, v8::CpuProfiler::FindProfile(uid3)); 389 CHECK_EQ(p3, cpu_profiler->FindCpuProfile(uid3));
388 const_cast<v8::CpuProfile*>(p2_t2)->Delete(); 390 const_cast<v8::CpuProfile*>(p2_t2)->Delete();
389 CHECK_EQ(1, v8::CpuProfiler::GetProfilesCount()); 391 CHECK_EQ(1, cpu_profiler->GetProfileCount());
390 CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid2)); 392 CHECK_EQ(NULL, cpu_profiler->FindCpuProfile(uid2));
391 CHECK_EQ(p3, v8::CpuProfiler::FindProfile(uid3)); 393 CHECK_EQ(p3, cpu_profiler->FindCpuProfile(uid3));
392 const_cast<v8::CpuProfile*>(p2)->Delete(); 394 const_cast<v8::CpuProfile*>(p2)->Delete();
393 CHECK_EQ(1, v8::CpuProfiler::GetProfilesCount()); 395 CHECK_EQ(1, cpu_profiler->GetProfileCount());
394 CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid2)); 396 CHECK_EQ(NULL, cpu_profiler->FindCpuProfile(uid2));
395 CHECK_EQ(p3, v8::CpuProfiler::FindProfile(uid3)); 397 CHECK_EQ(p3, cpu_profiler->FindCpuProfile(uid3));
396 const_cast<v8::CpuProfile*>(p3)->Delete(); 398 const_cast<v8::CpuProfile*>(p3)->Delete();
397 CHECK_EQ(0, v8::CpuProfiler::GetProfilesCount()); 399 CHECK_EQ(0, cpu_profiler->GetProfileCount());
398 CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid3)); 400 CHECK_EQ(NULL, cpu_profiler->FindCpuProfile(uid3));
399 } 401 }
OLDNEW
« no previous file with comments | « src/log.h ('k') | test/cctest/test-profile-generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698