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

Side by Side Diff: test/cctest/test-profile-generator.cc

Issue 2105943002: Expose TickSample and its APIs in v8-profiler.h (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebase & address comments. Created 4 years, 5 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
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 25 matching lines...) Expand all
36 #include "test/cctest/profiler-extension.h" 36 #include "test/cctest/profiler-extension.h"
37 37
38 using i::CodeEntry; 38 using i::CodeEntry;
39 using i::CodeMap; 39 using i::CodeMap;
40 using i::CpuProfile; 40 using i::CpuProfile;
41 using i::CpuProfiler; 41 using i::CpuProfiler;
42 using i::CpuProfilesCollection; 42 using i::CpuProfilesCollection;
43 using i::ProfileNode; 43 using i::ProfileNode;
44 using i::ProfileTree; 44 using i::ProfileTree;
45 using i::ProfileGenerator; 45 using i::ProfileGenerator;
46 using i::TickSample; 46 using v8::TickSample;
alph 2016/06/29 19:39:09 sort it?
lpy 2016/06/29 20:17:39 Done.
47 using i::Vector; 47 using i::Vector;
48 48
49 49
50 TEST(ProfileNodeFindOrAddChild) { 50 TEST(ProfileNodeFindOrAddChild) {
51 CcTest::InitializeVM(); 51 CcTest::InitializeVM();
52 ProfileTree tree(CcTest::i_isolate()); 52 ProfileTree tree(CcTest::i_isolate());
53 ProfileNode* node = tree.root(); 53 ProfileNode* node = tree.root();
54 CodeEntry entry1(i::CodeEventListener::FUNCTION_TAG, "aaa"); 54 CodeEntry entry1(i::CodeEventListener::FUNCTION_TAG, "aaa");
55 ProfileNode* childNode1 = node->FindOrAddChild(&entry1); 55 ProfileNode* childNode1 = node->FindOrAddChild(&entry1);
56 CHECK(childNode1); 56 CHECK(childNode1);
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 357
358 // We are building the following calls tree: 358 // We are building the following calls tree:
359 // -> aaa - sample1 359 // -> aaa - sample1
360 // aaa -> bbb -> ccc - sample2 360 // aaa -> bbb -> ccc - sample2
361 // -> ccc -> aaa - sample3 361 // -> ccc -> aaa - sample3
362 TickSample sample1; 362 TickSample sample1;
363 sample1.pc = ToAddress(0x1600); 363 sample1.pc = ToAddress(0x1600);
364 sample1.tos = ToAddress(0x1500); 364 sample1.tos = ToAddress(0x1500);
365 sample1.stack[0] = ToAddress(0x1510); 365 sample1.stack[0] = ToAddress(0x1510);
366 sample1.frames_count = 1; 366 sample1.frames_count = 1;
367 generator.RecordTickSample(sample1); 367 generator.RecordTickSample(sample1, v8::base::TimeTicks::HighResolutionNow());
368 TickSample sample2; 368 TickSample sample2;
369 sample2.pc = ToAddress(0x1925); 369 sample2.pc = ToAddress(0x1925);
370 sample2.tos = ToAddress(0x1900); 370 sample2.tos = ToAddress(0x1900);
371 sample2.stack[0] = ToAddress(0x1780); 371 sample2.stack[0] = ToAddress(0x1780);
372 sample2.stack[1] = ToAddress(0x10000); // non-existent. 372 sample2.stack[1] = ToAddress(0x10000); // non-existent.
373 sample2.stack[2] = ToAddress(0x1620); 373 sample2.stack[2] = ToAddress(0x1620);
374 sample2.frames_count = 3; 374 sample2.frames_count = 3;
375 generator.RecordTickSample(sample2); 375 generator.RecordTickSample(sample2, v8::base::TimeTicks::HighResolutionNow());
376 TickSample sample3; 376 TickSample sample3;
377 sample3.pc = ToAddress(0x1510); 377 sample3.pc = ToAddress(0x1510);
378 sample3.tos = ToAddress(0x1500); 378 sample3.tos = ToAddress(0x1500);
379 sample3.stack[0] = ToAddress(0x1910); 379 sample3.stack[0] = ToAddress(0x1910);
380 sample3.stack[1] = ToAddress(0x1610); 380 sample3.stack[1] = ToAddress(0x1610);
381 sample3.frames_count = 2; 381 sample3.frames_count = 2;
382 generator.RecordTickSample(sample3); 382 generator.RecordTickSample(sample3, v8::base::TimeTicks::HighResolutionNow());
383 383
384 CpuProfile* profile = profiles.StopProfiling(""); 384 CpuProfile* profile = profiles.StopProfiling("");
385 CHECK(profile); 385 CHECK(profile);
386 ProfileTreeTestHelper top_down_test_helper(profile->top_down()); 386 ProfileTreeTestHelper top_down_test_helper(profile->top_down());
387 CHECK(!top_down_test_helper.Walk(entry2)); 387 CHECK(!top_down_test_helper.Walk(entry2));
388 CHECK(!top_down_test_helper.Walk(entry3)); 388 CHECK(!top_down_test_helper.Walk(entry3));
389 ProfileNode* node1 = top_down_test_helper.Walk(entry1); 389 ProfileNode* node1 = top_down_test_helper.Walk(entry1);
390 CHECK(node1); 390 CHECK(node1);
391 CHECK_EQ(entry1, node1->entry()); 391 CHECK_EQ(entry1, node1->entry());
392 ProfileNode* node2 = top_down_test_helper.Walk(entry1, entry1); 392 ProfileNode* node2 = top_down_test_helper.Walk(entry1, entry1);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 CodeEntry* entry3 = new CodeEntry(i::Logger::FUNCTION_TAG, "ccc"); 424 CodeEntry* entry3 = new CodeEntry(i::Logger::FUNCTION_TAG, "ccc");
425 generator.code_map()->AddCode(ToAddress(0x1500), entry1, 0x200); 425 generator.code_map()->AddCode(ToAddress(0x1500), entry1, 0x200);
426 generator.code_map()->AddCode(ToAddress(0x1700), entry2, 0x100); 426 generator.code_map()->AddCode(ToAddress(0x1700), entry2, 0x100);
427 generator.code_map()->AddCode(ToAddress(0x1900), entry3, 0x50); 427 generator.code_map()->AddCode(ToAddress(0x1900), entry3, 0x50);
428 428
429 // We are building the following calls tree: 429 // We are building the following calls tree:
430 // -> aaa #3 - sample1 430 // -> aaa #3 - sample1
431 // (root)#1 -> aaa #2 -> bbb #4 -> ccc #5 - sample2 431 // (root)#1 -> aaa #2 -> bbb #4 -> ccc #5 - sample2
432 // -> ccc #6 -> aaa #7 - sample3 432 // -> ccc #6 -> aaa #7 - sample3
433 TickSample sample1; 433 TickSample sample1;
434 sample1.timestamp = v8::base::TimeTicks::HighResolutionNow();
435 sample1.pc = ToAddress(0x1600); 434 sample1.pc = ToAddress(0x1600);
436 sample1.stack[0] = ToAddress(0x1510); 435 sample1.stack[0] = ToAddress(0x1510);
437 sample1.frames_count = 1; 436 sample1.frames_count = 1;
438 generator.RecordTickSample(sample1); 437 generator.RecordTickSample(sample1, v8::base::TimeTicks::HighResolutionNow());
439 TickSample sample2; 438 TickSample sample2;
440 sample2.timestamp = v8::base::TimeTicks::HighResolutionNow();
441 sample2.pc = ToAddress(0x1925); 439 sample2.pc = ToAddress(0x1925);
442 sample2.stack[0] = ToAddress(0x1780); 440 sample2.stack[0] = ToAddress(0x1780);
443 sample2.stack[1] = ToAddress(0x10000); // non-existent. 441 sample2.stack[1] = ToAddress(0x10000); // non-existent.
444 sample2.stack[2] = ToAddress(0x1620); 442 sample2.stack[2] = ToAddress(0x1620);
445 sample2.frames_count = 3; 443 sample2.frames_count = 3;
446 generator.RecordTickSample(sample2); 444 generator.RecordTickSample(sample2, v8::base::TimeTicks::HighResolutionNow());
447 TickSample sample3; 445 TickSample sample3;
448 sample3.timestamp = v8::base::TimeTicks::HighResolutionNow();
449 sample3.pc = ToAddress(0x1510); 446 sample3.pc = ToAddress(0x1510);
450 sample3.stack[0] = ToAddress(0x1910); 447 sample3.stack[0] = ToAddress(0x1910);
451 sample3.stack[1] = ToAddress(0x1610); 448 sample3.stack[1] = ToAddress(0x1610);
452 sample3.frames_count = 2; 449 sample3.frames_count = 2;
453 generator.RecordTickSample(sample3); 450 generator.RecordTickSample(sample3, v8::base::TimeTicks::HighResolutionNow());
454 451
455 CpuProfile* profile = profiles.StopProfiling(""); 452 CpuProfile* profile = profiles.StopProfiling("");
456 unsigned nodeId = 1; 453 unsigned nodeId = 1;
457 CheckNodeIds(profile->top_down()->root(), &nodeId); 454 CheckNodeIds(profile->top_down()->root(), &nodeId);
458 CHECK_EQ(7u, nodeId - 1); 455 CHECK_EQ(7u, nodeId - 1);
459 456
460 CHECK_EQ(3, profile->samples_count()); 457 CHECK_EQ(3, profile->samples_count());
461 unsigned expected_id[] = {3, 5, 7}; 458 unsigned expected_id[] = {3, 5, 7};
462 for (int i = 0; i < 3; i++) { 459 for (int i = 0; i < 3; i++) {
463 CHECK_EQ(expected_id[i], profile->sample(i)->id()); 460 CHECK_EQ(expected_id[i], profile->sample(i)->id());
(...skipping 13 matching lines...) Expand all
477 ProfileGenerator generator(&profiles); 474 ProfileGenerator generator(&profiles);
478 CodeEntry* entry1 = new CodeEntry(i::Logger::FUNCTION_TAG, "aaa"); 475 CodeEntry* entry1 = new CodeEntry(i::Logger::FUNCTION_TAG, "aaa");
479 generator.code_map()->AddCode(ToAddress(0x1500), entry1, 0x200); 476 generator.code_map()->AddCode(ToAddress(0x1500), entry1, 0x200);
480 477
481 // We are building the following calls tree: 478 // We are building the following calls tree:
482 // (root)#1 -> aaa #2 -> aaa #3 - sample1 479 // (root)#1 -> aaa #2 -> aaa #3 - sample1
483 TickSample sample1; 480 TickSample sample1;
484 sample1.pc = ToAddress(0x1600); 481 sample1.pc = ToAddress(0x1600);
485 sample1.stack[0] = ToAddress(0x1510); 482 sample1.stack[0] = ToAddress(0x1510);
486 sample1.frames_count = 1; 483 sample1.frames_count = 1;
487 generator.RecordTickSample(sample1); 484 generator.RecordTickSample(sample1, v8::base::TimeTicks::HighResolutionNow());
488 485
489 CpuProfile* profile = profiles.StopProfiling(""); 486 CpuProfile* profile = profiles.StopProfiling("");
490 unsigned nodeId = 1; 487 unsigned nodeId = 1;
491 CheckNodeIds(profile->top_down()->root(), &nodeId); 488 CheckNodeIds(profile->top_down()->root(), &nodeId);
492 CHECK_EQ(3u, nodeId - 1); 489 CHECK_EQ(3u, nodeId - 1);
493 490
494 CHECK_EQ(0, profile->samples_count()); 491 CHECK_EQ(0, profile->samples_count());
495 492
496 delete entry1; 493 delete entry1;
497 } 494 }
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
718 // (root) 715 // (root)
719 // "" 716 // ""
720 // kDebuggerStatement 717 // kDebuggerStatement
721 current = PickChild(current, ""); 718 current = PickChild(current, "");
722 CHECK(const_cast<v8::CpuProfileNode*>(current)); 719 CHECK(const_cast<v8::CpuProfileNode*>(current));
723 720
724 current = PickChild(current, "Debugger"); 721 current = PickChild(current, "Debugger");
725 CHECK(const_cast<v8::CpuProfileNode*>(current)); 722 CHECK(const_cast<v8::CpuProfileNode*>(current));
726 CHECK(!strcmp("DebuggerStatement", current->GetBailoutReason())); 723 CHECK(!strcmp("DebuggerStatement", current->GetBailoutReason()));
727 } 724 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698