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

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

Issue 5862002: Version 3.0.2. (Closed)
Patch Set: Created 10 years 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 // 2 //
3 // Tests of profiles generator and utilities. 3 // Tests of profiles generator and utilities.
4 4
5 #ifdef ENABLE_LOGGING_AND_PROFILING 5 #ifdef ENABLE_LOGGING_AND_PROFILING
6 6
7 #include "v8.h" 7 #include "v8.h"
8 #include "profile-generator-inl.h" 8 #include "profile-generator-inl.h"
9 #include "cctest.h" 9 #include "cctest.h"
10 #include "../include/v8-profiler.h" 10 #include "../include/v8-profiler.h"
(...skipping 764 matching lines...) Expand 10 before | Expand all | Expand 10 after
775 "function c() { startProfiling(); }\n" 775 "function c() { startProfiling(); }\n"
776 "function b() { c(); }\n" 776 "function b() { c(); }\n"
777 "function a() { b(); }\n" 777 "function a() { b(); }\n"
778 "a();\n" 778 "a();\n"
779 "stopProfiling();"); 779 "stopProfiling();");
780 CHECK_EQ(1, CpuProfiler::GetProfilesCount()); 780 CHECK_EQ(1, CpuProfiler::GetProfilesCount());
781 CpuProfile* profile = 781 CpuProfile* profile =
782 CpuProfiler::GetProfile(NULL, 0); 782 CpuProfiler::GetProfile(NULL, 0);
783 const ProfileTree* topDown = profile->top_down(); 783 const ProfileTree* topDown = profile->top_down();
784 const ProfileNode* current = topDown->root(); 784 const ProfileNode* current = topDown->root();
785 const_cast<ProfileNode*>(current)->Print(0);
786 // The tree should look like this: 785 // The tree should look like this:
787 // (root) 786 // (root)
788 // (anonymous function) 787 // (anonymous function)
789 // a 788 // a
790 // b 789 // b
791 // c 790 // c
792 // There can also be:
793 // startProfiling
794 // if the sampler managed to get a tick.
795 current = PickChild(current, "(anonymous function)"); 791 current = PickChild(current, "(anonymous function)");
796 CHECK_NE(NULL, const_cast<ProfileNode*>(current)); 792 CHECK_NE(NULL, const_cast<ProfileNode*>(current));
797 current = PickChild(current, "a"); 793 current = PickChild(current, "a");
798 CHECK_NE(NULL, const_cast<ProfileNode*>(current)); 794 CHECK_NE(NULL, const_cast<ProfileNode*>(current));
799 current = PickChild(current, "b"); 795 current = PickChild(current, "b");
800 CHECK_NE(NULL, const_cast<ProfileNode*>(current)); 796 CHECK_NE(NULL, const_cast<ProfileNode*>(current));
801 current = PickChild(current, "c"); 797 current = PickChild(current, "c");
802 CHECK_NE(NULL, const_cast<ProfileNode*>(current)); 798 CHECK_NE(NULL, const_cast<ProfileNode*>(current));
803 CHECK(current->children()->length() == 0 || 799 CHECK_EQ(0, current->children()->length());
804 current->children()->length() == 1);
805 if (current->children()->length() == 1) {
806 current = PickChild(current, "startProfiling");
807 CHECK_EQ(0, current->children()->length());
808 }
809 } 800 }
810 801
811 802
812 TEST(Issue51919) { 803 TEST(Issue51919) {
813 CpuProfilesCollection collection; 804 CpuProfilesCollection collection;
814 i::EmbeddedVector<char*, 805 i::EmbeddedVector<char*,
815 CpuProfilesCollection::kMaxSimultaneousProfiles> titles; 806 CpuProfilesCollection::kMaxSimultaneousProfiles> titles;
816 for (int i = 0; i < CpuProfilesCollection::kMaxSimultaneousProfiles; ++i) { 807 for (int i = 0; i < CpuProfilesCollection::kMaxSimultaneousProfiles; ++i) {
817 i::Vector<char> title = i::Vector<char>::New(16); 808 i::Vector<char> title = i::Vector<char>::New(16);
818 i::OS::SNPrintF(title, "%d", i); 809 i::OS::SNPrintF(title, "%d", i);
819 CHECK(collection.StartProfiling(title.start(), i + 1)); // UID must be > 0. 810 CHECK(collection.StartProfiling(title.start(), i + 1)); // UID must be > 0.
820 titles[i] = title.start(); 811 titles[i] = title.start();
821 } 812 }
822 CHECK(!collection.StartProfiling( 813 CHECK(!collection.StartProfiling(
823 "maximum", CpuProfilesCollection::kMaxSimultaneousProfiles + 1)); 814 "maximum", CpuProfilesCollection::kMaxSimultaneousProfiles + 1));
824 for (int i = 0; i < CpuProfilesCollection::kMaxSimultaneousProfiles; ++i) 815 for (int i = 0; i < CpuProfilesCollection::kMaxSimultaneousProfiles; ++i)
825 i::DeleteArray(titles[i]); 816 i::DeleteArray(titles[i]);
826 } 817 }
827 818
828 #endif // ENABLE_LOGGING_AND_PROFILING 819 #endif // ENABLE_LOGGING_AND_PROFILING
OLDNEW
« ChangeLog ('K') | « test/cctest/test-parsing.cc ('k') | test/cctest/test-regexp.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698