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

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

Issue 1635005: Allow new CPU profiling subsystem to coexist nicely with the old one. (Closed)
Patch Set: Fix TickSampleEvent Created 10 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
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_CPP_PROFILES_PROCESSOR 5 #ifdef ENABLE_CPP_PROFILES_PROCESSOR
6 6
7 #include "v8.h" 7 #include "v8.h"
8 #include "cpu-profiler-inl.h" 8 #include "cpu-profiler-inl.h"
9 #include "cctest.h" 9 #include "cctest.h"
10 10
(...skipping 29 matching lines...) Expand all
40 40
41 static inline i::Address ToAddress(int n) { 41 static inline i::Address ToAddress(int n) {
42 return reinterpret_cast<i::Address>(n); 42 return reinterpret_cast<i::Address>(n);
43 } 43 }
44 44
45 static void EnqueueTickSampleEvent(ProfilerEventsProcessor* proc, 45 static void EnqueueTickSampleEvent(ProfilerEventsProcessor* proc,
46 i::Address frame1, 46 i::Address frame1,
47 i::Address frame2 = NULL, 47 i::Address frame2 = NULL,
48 i::Address frame3 = NULL) { 48 i::Address frame3 = NULL) {
49 i::TickSample* sample = proc->TickSampleEvent(); 49 i::TickSample* sample = proc->TickSampleEvent();
50 sample->state = i::OTHER;
51 sample->pc = frame1; 50 sample->pc = frame1;
52 sample->function = frame1; 51 sample->function = frame1;
53 sample->frames_count = 0; 52 sample->frames_count = 0;
54 if (frame2 != NULL) { 53 if (frame2 != NULL) {
55 sample->stack[0] = frame2; 54 sample->stack[0] = frame2;
56 sample->frames_count = 1; 55 sample->frames_count = 1;
57 } 56 }
58 if (frame3 != NULL) { 57 if (frame3 != NULL) {
59 sample->stack[1] = frame3; 58 sample->stack[1] = frame3;
60 sample->frames_count = 2; 59 sample->frames_count = 2;
61 } 60 }
62 } 61 }
63 62
63 namespace {
64
65 class TestSetup {
66 public:
67 TestSetup()
68 : old_flag_prof_browser_mode_(i::FLAG_prof_browser_mode) {
69 i::FLAG_prof_browser_mode = false;
70 }
71
72 ~TestSetup() {
73 i::FLAG_prof_browser_mode = old_flag_prof_browser_mode_;
74 }
75
76 private:
77 bool old_flag_prof_browser_mode_;
78 };
79
80 } // namespace
81
64 TEST(CodeEvents) { 82 TEST(CodeEvents) {
65 InitializeVM(); 83 InitializeVM();
84 TestSetup test_setup;
66 CpuProfilesCollection profiles; 85 CpuProfilesCollection profiles;
67 profiles.StartProfiling("", 1); 86 profiles.StartProfiling("", 1);
68 ProfileGenerator generator(&profiles); 87 ProfileGenerator generator(&profiles);
69 ProfilerEventsProcessor processor(&generator); 88 ProfilerEventsProcessor processor(&generator);
70 processor.Start(); 89 processor.Start();
71 while (!processor.running()) { 90 while (!processor.running()) {
72 i::Thread::YieldCPU(); 91 i::Thread::YieldCPU();
73 } 92 }
74 93
75 // Enqueue code creation events. 94 // Enqueue code creation events.
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 CHECK_EQ(aaa_str, entry5->name()); 141 CHECK_EQ(aaa_str, entry5->name());
123 } 142 }
124 143
125 144
126 template<typename T> 145 template<typename T>
127 static int CompareProfileNodes(const T* p1, const T* p2) { 146 static int CompareProfileNodes(const T* p1, const T* p2) {
128 return strcmp((*p1)->entry()->name(), (*p2)->entry()->name()); 147 return strcmp((*p1)->entry()->name(), (*p2)->entry()->name());
129 } 148 }
130 149
131 TEST(TickEvents) { 150 TEST(TickEvents) {
151 TestSetup test_setup;
132 CpuProfilesCollection profiles; 152 CpuProfilesCollection profiles;
133 profiles.StartProfiling("", 1); 153 profiles.StartProfiling("", 1);
134 ProfileGenerator generator(&profiles); 154 ProfileGenerator generator(&profiles);
135 ProfilerEventsProcessor processor(&generator); 155 ProfilerEventsProcessor processor(&generator);
136 processor.Start(); 156 processor.Start();
137 while (!processor.running()) { 157 while (!processor.running()) {
138 i::Thread::YieldCPU(); 158 i::Thread::YieldCPU();
139 } 159 }
140 160
141 processor.CodeCreateEvent(i::Logger::BUILTIN_TAG, 161 processor.CodeCreateEvent(i::Logger::BUILTIN_TAG,
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 bottom_up_root_children[2]->children(); 216 bottom_up_root_children[2]->children();
197 CHECK_EQ(1, bottom_up_ddd_children->length()); 217 CHECK_EQ(1, bottom_up_ddd_children->length());
198 CHECK_EQ("5", bottom_up_ddd_children->last()->entry()->name()); 218 CHECK_EQ("5", bottom_up_ddd_children->last()->entry()->name());
199 const i::List<ProfileNode*>* bottom_up_ddd_stub_children = 219 const i::List<ProfileNode*>* bottom_up_ddd_stub_children =
200 bottom_up_ddd_children->last()->children(); 220 bottom_up_ddd_children->last()->children();
201 CHECK_EQ(1, bottom_up_ddd_stub_children->length()); 221 CHECK_EQ(1, bottom_up_ddd_stub_children->length());
202 CHECK_EQ("bbb", bottom_up_ddd_stub_children->last()->entry()->name()); 222 CHECK_EQ("bbb", bottom_up_ddd_stub_children->last()->entry()->name());
203 } 223 }
204 224
205 #endif // ENABLE_CPP_PROFILES_PROCESSOR 225 #endif // ENABLE_CPP_PROFILES_PROCESSOR
OLDNEW
« src/cpu-profiler-inl.h ('K') | « src/v8.cc ('k') | test/cctest/test-profile-generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698