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

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

Issue 5598008: Fix RecordStackTraceAtStartProfiling test. (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
« no previous file with comments | « test/cctest/cctest.status ('k') | no next file » | 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 // 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);
785 // The tree should look like this: 786 // The tree should look like this:
786 // (root) 787 // (root)
787 // (anonymous function) 788 // (anonymous function)
788 // a 789 // a
789 // b 790 // b
790 // c 791 // c
792 // There can also be:
793 // startProfiling
794 // if the sampler managed to get a tick.
791 current = PickChild(current, "(anonymous function)"); 795 current = PickChild(current, "(anonymous function)");
792 CHECK_NE(NULL, const_cast<ProfileNode*>(current)); 796 CHECK_NE(NULL, const_cast<ProfileNode*>(current));
793 current = PickChild(current, "a"); 797 current = PickChild(current, "a");
794 CHECK_NE(NULL, const_cast<ProfileNode*>(current)); 798 CHECK_NE(NULL, const_cast<ProfileNode*>(current));
795 current = PickChild(current, "b"); 799 current = PickChild(current, "b");
796 CHECK_NE(NULL, const_cast<ProfileNode*>(current)); 800 CHECK_NE(NULL, const_cast<ProfileNode*>(current));
797 current = PickChild(current, "c"); 801 current = PickChild(current, "c");
798 CHECK_NE(NULL, const_cast<ProfileNode*>(current)); 802 CHECK_NE(NULL, const_cast<ProfileNode*>(current));
799 CHECK_EQ(0, current->children()->length()); 803 CHECK(current->children()->length() == 0 ||
804 current->children()->length() == 1);
805 if (current->children()->length() == 1) {
806 current = PickChild(current, "startProfiling");
807 CHECK_EQ(0, current->children()->length());
808 }
800 } 809 }
801 810
802 811
803 TEST(Issue51919) { 812 TEST(Issue51919) {
804 CpuProfilesCollection collection; 813 CpuProfilesCollection collection;
805 i::EmbeddedVector<char*, 814 i::EmbeddedVector<char*,
806 CpuProfilesCollection::kMaxSimultaneousProfiles> titles; 815 CpuProfilesCollection::kMaxSimultaneousProfiles> titles;
807 for (int i = 0; i < CpuProfilesCollection::kMaxSimultaneousProfiles; ++i) { 816 for (int i = 0; i < CpuProfilesCollection::kMaxSimultaneousProfiles; ++i) {
808 i::Vector<char> title = i::Vector<char>::New(16); 817 i::Vector<char> title = i::Vector<char>::New(16);
809 i::OS::SNPrintF(title, "%d", i); 818 i::OS::SNPrintF(title, "%d", i);
810 CHECK(collection.StartProfiling(title.start(), i + 1)); // UID must be > 0. 819 CHECK(collection.StartProfiling(title.start(), i + 1)); // UID must be > 0.
811 titles[i] = title.start(); 820 titles[i] = title.start();
812 } 821 }
813 CHECK(!collection.StartProfiling( 822 CHECK(!collection.StartProfiling(
814 "maximum", CpuProfilesCollection::kMaxSimultaneousProfiles + 1)); 823 "maximum", CpuProfilesCollection::kMaxSimultaneousProfiles + 1));
815 for (int i = 0; i < CpuProfilesCollection::kMaxSimultaneousProfiles; ++i) 824 for (int i = 0; i < CpuProfilesCollection::kMaxSimultaneousProfiles; ++i)
816 i::DeleteArray(titles[i]); 825 i::DeleteArray(titles[i]);
817 } 826 }
818 827
819 #endif // ENABLE_LOGGING_AND_PROFILING 828 #endif // ENABLE_LOGGING_AND_PROFILING
OLDNEW
« no previous file with comments | « test/cctest/cctest.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698