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

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

Issue 1514006: C++ profiles processor: put under #ifdef and fix issues. (Closed)
Patch Set: 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
6
5 #include "v8.h" 7 #include "v8.h"
6 #include "cpu-profiler-inl.h" 8 #include "cpu-profiler-inl.h"
7 #include "cctest.h" 9 #include "cctest.h"
8 10
9 namespace i = v8::internal; 11 namespace i = v8::internal;
10 12
11 using i::CodeEntry; 13 using i::CodeEntry;
14 using i::CpuProfile;
12 using i::CpuProfilesCollection; 15 using i::CpuProfilesCollection;
13 using i::ProfileGenerator; 16 using i::ProfileGenerator;
14 using i::ProfileNode; 17 using i::ProfileNode;
15 using i::ProfilerEventsProcessor; 18 using i::ProfilerEventsProcessor;
16 19
17 20
18 TEST(StartStop) { 21 TEST(StartStop) {
19 CpuProfilesCollection profiles; 22 CpuProfilesCollection profiles;
20 ProfileGenerator generator(&profiles); 23 ProfileGenerator generator(&profiles);
21 ProfilerEventsProcessor processor(&generator); 24 ProfilerEventsProcessor processor(&generator);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 } 56 }
54 if (frame3 != NULL) { 57 if (frame3 != NULL) {
55 sample->stack[1] = frame3; 58 sample->stack[1] = frame3;
56 sample->frames_count = 2; 59 sample->frames_count = 2;
57 } 60 }
58 } 61 }
59 62
60 TEST(CodeEvents) { 63 TEST(CodeEvents) {
61 InitializeVM(); 64 InitializeVM();
62 CpuProfilesCollection profiles; 65 CpuProfilesCollection profiles;
63 profiles.AddProfile(0); 66 profiles.StartProfiling("", 1);
64 ProfileGenerator generator(&profiles); 67 ProfileGenerator generator(&profiles);
65 ProfilerEventsProcessor processor(&generator); 68 ProfilerEventsProcessor processor(&generator);
66 processor.Start(); 69 processor.Start();
67 while (!processor.running()) { 70 while (!processor.running()) {
68 i::Thread::YieldCPU(); 71 i::Thread::YieldCPU();
69 } 72 }
70 73
71 // Enqueue code creation events. 74 // Enqueue code creation events.
72 i::HandleScope scope; 75 i::HandleScope scope;
73 const char* aaa_str = "aaa"; 76 const char* aaa_str = "aaa";
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 } 122 }
120 123
121 124
122 template<typename T> 125 template<typename T>
123 static int CompareProfileNodes(const T* p1, const T* p2) { 126 static int CompareProfileNodes(const T* p1, const T* p2) {
124 return strcmp((*p1)->entry()->name(), (*p2)->entry()->name()); 127 return strcmp((*p1)->entry()->name(), (*p2)->entry()->name());
125 } 128 }
126 129
127 TEST(TickEvents) { 130 TEST(TickEvents) {
128 CpuProfilesCollection profiles; 131 CpuProfilesCollection profiles;
129 profiles.AddProfile(0); 132 profiles.StartProfiling("", 1);
130 ProfileGenerator generator(&profiles); 133 ProfileGenerator generator(&profiles);
131 ProfilerEventsProcessor processor(&generator); 134 ProfilerEventsProcessor processor(&generator);
132 processor.Start(); 135 processor.Start();
133 while (!processor.running()) { 136 while (!processor.running()) {
134 i::Thread::YieldCPU(); 137 i::Thread::YieldCPU();
135 } 138 }
136 139
137 processor.CodeCreateEvent(i::Logger::BUILTIN_TAG, 140 processor.CodeCreateEvent(i::Logger::BUILTIN_TAG,
138 "bbb", 141 "bbb",
139 ToAddress(0x1200), 142 ToAddress(0x1200),
140 0x80); 143 0x80);
141 processor.CodeCreateEvent(i::Logger::STUB_TAG, 5, ToAddress(0x1300), 0x10); 144 processor.CodeCreateEvent(i::Logger::STUB_TAG, 5, ToAddress(0x1300), 0x10);
142 processor.CodeCreateEvent(i::Logger::BUILTIN_TAG, 145 processor.CodeCreateEvent(i::Logger::BUILTIN_TAG,
143 "ddd", 146 "ddd",
144 ToAddress(0x1400), 147 ToAddress(0x1400),
145 0x80); 148 0x80);
146 EnqueueTickSampleEvent(&processor, ToAddress(0x1210)); 149 EnqueueTickSampleEvent(&processor, ToAddress(0x1210));
147 EnqueueTickSampleEvent(&processor, ToAddress(0x1305), ToAddress(0x1220)); 150 EnqueueTickSampleEvent(&processor, ToAddress(0x1305), ToAddress(0x1220));
148 EnqueueTickSampleEvent(&processor, 151 EnqueueTickSampleEvent(&processor,
149 ToAddress(0x1404), 152 ToAddress(0x1404),
150 ToAddress(0x1305), 153 ToAddress(0x1305),
151 ToAddress(0x1230)); 154 ToAddress(0x1230));
152 155
153 processor.Stop(); 156 processor.Stop();
154 processor.Join(); 157 processor.Join();
158 CpuProfile* profile = profiles.StopProfiling("");
159 CHECK_NE(NULL, profile);
155 160
156 // Check call trees. 161 // Check call trees.
157 i::List<ProfileNode*> top_down_root_children; 162 const i::List<ProfileNode*>* top_down_root_children =
158 profiles.profile()->top_down()->root()->GetChildren(&top_down_root_children); 163 profile->top_down()->root()->children();
159 CHECK_EQ(1, top_down_root_children.length()); 164 CHECK_EQ(1, top_down_root_children->length());
160 CHECK_EQ("bbb", top_down_root_children.last()->entry()->name()); 165 CHECK_EQ("bbb", top_down_root_children->last()->entry()->name());
161 i::List<ProfileNode*> top_down_bbb_children; 166 const i::List<ProfileNode*>* top_down_bbb_children =
162 top_down_root_children.last()->GetChildren(&top_down_bbb_children); 167 top_down_root_children->last()->children();
163 CHECK_EQ(1, top_down_bbb_children.length()); 168 CHECK_EQ(1, top_down_bbb_children->length());
164 CHECK_EQ("args_count: 5", top_down_bbb_children.last()->entry()->name()); 169 CHECK_EQ("args_count: 5", top_down_bbb_children->last()->entry()->name());
165 i::List<ProfileNode*> top_down_stub_children; 170 const i::List<ProfileNode*>* top_down_stub_children =
166 top_down_bbb_children.last()->GetChildren(&top_down_stub_children); 171 top_down_bbb_children->last()->children();
167 CHECK_EQ(1, top_down_stub_children.length()); 172 CHECK_EQ(1, top_down_stub_children->length());
168 CHECK_EQ("ddd", top_down_stub_children.last()->entry()->name()); 173 CHECK_EQ("ddd", top_down_stub_children->last()->entry()->name());
169 i::List<ProfileNode*> top_down_ddd_children; 174 const i::List<ProfileNode*>* top_down_ddd_children =
170 top_down_stub_children.last()->GetChildren(&top_down_ddd_children); 175 top_down_stub_children->last()->children();
171 CHECK_EQ(0, top_down_ddd_children.length()); 176 CHECK_EQ(0, top_down_ddd_children->length());
172 177
173 i::List<ProfileNode*> bottom_up_root_children; 178 const i::List<ProfileNode*>* bottom_up_root_children_unsorted =
174 profiles.profile()->bottom_up()->root()->GetChildren( 179 profile->bottom_up()->root()->children();
175 &bottom_up_root_children); 180 CHECK_EQ(3, bottom_up_root_children_unsorted->length());
176 CHECK_EQ(3, bottom_up_root_children.length()); 181 i::List<ProfileNode*> bottom_up_root_children(3);
182 bottom_up_root_children.AddAll(*bottom_up_root_children_unsorted);
177 bottom_up_root_children.Sort(&CompareProfileNodes); 183 bottom_up_root_children.Sort(&CompareProfileNodes);
178 CHECK_EQ("args_count: 5", bottom_up_root_children[0]->entry()->name()); 184 CHECK_EQ("args_count: 5", bottom_up_root_children[0]->entry()->name());
179 CHECK_EQ("bbb", bottom_up_root_children[1]->entry()->name()); 185 CHECK_EQ("bbb", bottom_up_root_children[1]->entry()->name());
180 CHECK_EQ("ddd", bottom_up_root_children[2]->entry()->name()); 186 CHECK_EQ("ddd", bottom_up_root_children[2]->entry()->name());
181 i::List<ProfileNode*> bottom_up_stub_children; 187 const i::List<ProfileNode*>* bottom_up_stub_children =
182 bottom_up_root_children[0]->GetChildren(&bottom_up_stub_children); 188 bottom_up_root_children[0]->children();
183 CHECK_EQ(1, bottom_up_stub_children.length()); 189 CHECK_EQ(1, bottom_up_stub_children->length());
184 CHECK_EQ("bbb", bottom_up_stub_children.last()->entry()->name()); 190 CHECK_EQ("bbb", bottom_up_stub_children->last()->entry()->name());
185 i::List<ProfileNode*> bottom_up_bbb_children; 191 const i::List<ProfileNode*>* bottom_up_bbb_children =
186 bottom_up_root_children[1]->GetChildren(&bottom_up_bbb_children); 192 bottom_up_root_children[1]->children();
187 CHECK_EQ(0, bottom_up_bbb_children.length()); 193 CHECK_EQ(0, bottom_up_bbb_children->length());
188 i::List<ProfileNode*> bottom_up_ddd_children; 194 const i::List<ProfileNode*>* bottom_up_ddd_children =
189 bottom_up_root_children[2]->GetChildren(&bottom_up_ddd_children); 195 bottom_up_root_children[2]->children();
190 CHECK_EQ(1, bottom_up_ddd_children.length()); 196 CHECK_EQ(1, bottom_up_ddd_children->length());
191 CHECK_EQ("args_count: 5", bottom_up_ddd_children.last()->entry()->name()); 197 CHECK_EQ("args_count: 5", bottom_up_ddd_children->last()->entry()->name());
192 i::List<ProfileNode*> bottom_up_ddd_stub_children; 198 const i::List<ProfileNode*>* bottom_up_ddd_stub_children =
193 bottom_up_ddd_children.last()->GetChildren(&bottom_up_ddd_stub_children); 199 bottom_up_ddd_children->last()->children();
194 CHECK_EQ(1, bottom_up_ddd_stub_children.length()); 200 CHECK_EQ(1, bottom_up_ddd_stub_children->length());
195 CHECK_EQ("bbb", bottom_up_ddd_stub_children.last()->entry()->name()); 201 CHECK_EQ("bbb", bottom_up_ddd_stub_children->last()->entry()->name());
196 } 202 }
203
204 #endif // ENABLE_CPP_PROFILES_PROCESSOR
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698