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

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

Issue 907353003: Remove obsolete method ProfileTree::AddPathFromStart and the corresponding test. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 10 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
« no previous file with comments | « src/profile-generator.cc ('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 // 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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 } 110 }
111 return node; 111 return node;
112 } 112 }
113 113
114 private: 114 private:
115 const ProfileTree* tree_; 115 const ProfileTree* tree_;
116 }; 116 };
117 117
118 } // namespace 118 } // namespace
119 119
120 TEST(ProfileTreeAddPathFromStart) {
121 CodeEntry entry1(i::Logger::FUNCTION_TAG, "aaa");
122 CodeEntry entry2(i::Logger::FUNCTION_TAG, "bbb");
123 CodeEntry entry3(i::Logger::FUNCTION_TAG, "ccc");
124 ProfileTree tree;
125 ProfileTreeTestHelper helper(&tree);
126 CHECK(!helper.Walk(&entry1));
127 CHECK(!helper.Walk(&entry2));
128 CHECK(!helper.Walk(&entry3));
129
130 CodeEntry* path[] = {NULL, &entry1, NULL, &entry2, NULL, NULL, &entry3, NULL};
131 Vector<CodeEntry*> path_vec(path, sizeof(path) / sizeof(path[0]));
132 tree.AddPathFromStart(path_vec);
133 CHECK(!helper.Walk(&entry2));
134 CHECK(!helper.Walk(&entry3));
135 ProfileNode* node1 = helper.Walk(&entry1);
136 CHECK(node1);
137 CHECK_EQ(0u, node1->self_ticks());
138 CHECK(!helper.Walk(&entry1, &entry1));
139 CHECK(!helper.Walk(&entry1, &entry3));
140 ProfileNode* node2 = helper.Walk(&entry1, &entry2);
141 CHECK(node2);
142 CHECK_NE(node1, node2);
143 CHECK_EQ(0u, node2->self_ticks());
144 CHECK(!helper.Walk(&entry1, &entry2, &entry1));
145 CHECK(!helper.Walk(&entry1, &entry2, &entry2));
146 ProfileNode* node3 = helper.Walk(&entry1, &entry2, &entry3);
147 CHECK(node3);
148 CHECK_NE(node1, node3);
149 CHECK_NE(node2, node3);
150 CHECK_EQ(1u, node3->self_ticks());
151
152 tree.AddPathFromStart(path_vec);
153 CHECK_EQ(node1, helper.Walk(&entry1));
154 CHECK_EQ(node2, helper.Walk(&entry1, &entry2));
155 CHECK_EQ(node3, helper.Walk(&entry1, &entry2, &entry3));
156 CHECK_EQ(0u, node1->self_ticks());
157 CHECK_EQ(0u, node2->self_ticks());
158 CHECK_EQ(2u, node3->self_ticks());
159
160 CodeEntry* path2[] = {&entry1, &entry2, &entry2};
161 Vector<CodeEntry*> path2_vec(path2, sizeof(path2) / sizeof(path2[0]));
162 tree.AddPathFromStart(path2_vec);
163 CHECK(!helper.Walk(&entry2));
164 CHECK(!helper.Walk(&entry3));
165 CHECK_EQ(node1, helper.Walk(&entry1));
166 CHECK(!helper.Walk(&entry1, &entry1));
167 CHECK(!helper.Walk(&entry1, &entry3));
168 CHECK_EQ(node2, helper.Walk(&entry1, &entry2));
169 CHECK(!helper.Walk(&entry1, &entry2, &entry1));
170 CHECK_EQ(node3, helper.Walk(&entry1, &entry2, &entry3));
171 CHECK_EQ(2u, node3->self_ticks());
172 ProfileNode* node4 = helper.Walk(&entry1, &entry2, &entry2);
173 CHECK(node4);
174 CHECK_NE(node3, node4);
175 CHECK_EQ(1u, node4->self_ticks());
176 }
177
178 120
179 TEST(ProfileTreeAddPathFromEnd) { 121 TEST(ProfileTreeAddPathFromEnd) {
180 CodeEntry entry1(i::Logger::FUNCTION_TAG, "aaa"); 122 CodeEntry entry1(i::Logger::FUNCTION_TAG, "aaa");
181 CodeEntry entry2(i::Logger::FUNCTION_TAG, "bbb"); 123 CodeEntry entry2(i::Logger::FUNCTION_TAG, "bbb");
182 CodeEntry entry3(i::Logger::FUNCTION_TAG, "ccc"); 124 CodeEntry entry3(i::Logger::FUNCTION_TAG, "ccc");
183 ProfileTree tree; 125 ProfileTree tree;
184 ProfileTreeTestHelper helper(&tree); 126 ProfileTreeTestHelper helper(&tree);
185 CHECK(!helper.Walk(&entry1)); 127 CHECK(!helper.Walk(&entry1));
186 CHECK(!helper.Walk(&entry2)); 128 CHECK(!helper.Walk(&entry2));
187 CHECK(!helper.Walk(&entry3)); 129 CHECK(!helper.Walk(&entry3));
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 CHECK_EQ(0u, empty_tree.root()->self_ticks()); 182 CHECK_EQ(0u, empty_tree.root()->self_ticks());
241 empty_tree.root()->IncrementSelfTicks(); 183 empty_tree.root()->IncrementSelfTicks();
242 CHECK_EQ(1u, empty_tree.root()->self_ticks()); 184 CHECK_EQ(1u, empty_tree.root()->self_ticks());
243 185
244 CodeEntry entry1(i::Logger::FUNCTION_TAG, "aaa"); 186 CodeEntry entry1(i::Logger::FUNCTION_TAG, "aaa");
245 CodeEntry* e1_path[] = {&entry1}; 187 CodeEntry* e1_path[] = {&entry1};
246 Vector<CodeEntry*> e1_path_vec( 188 Vector<CodeEntry*> e1_path_vec(
247 e1_path, sizeof(e1_path) / sizeof(e1_path[0])); 189 e1_path, sizeof(e1_path) / sizeof(e1_path[0]));
248 190
249 ProfileTree single_child_tree; 191 ProfileTree single_child_tree;
250 single_child_tree.AddPathFromStart(e1_path_vec); 192 single_child_tree.AddPathFromEnd(e1_path_vec);
251 single_child_tree.root()->IncrementSelfTicks(); 193 single_child_tree.root()->IncrementSelfTicks();
252 CHECK_EQ(1u, single_child_tree.root()->self_ticks()); 194 CHECK_EQ(1u, single_child_tree.root()->self_ticks());
253 ProfileTreeTestHelper single_child_helper(&single_child_tree); 195 ProfileTreeTestHelper single_child_helper(&single_child_tree);
254 ProfileNode* node1 = single_child_helper.Walk(&entry1); 196 ProfileNode* node1 = single_child_helper.Walk(&entry1);
255 CHECK(node1); 197 CHECK(node1);
256 CHECK_EQ(1u, single_child_tree.root()->self_ticks()); 198 CHECK_EQ(1u, single_child_tree.root()->self_ticks());
257 CHECK_EQ(1u, node1->self_ticks()); 199 CHECK_EQ(1u, node1->self_ticks());
258 200
259 CodeEntry entry2(i::Logger::FUNCTION_TAG, "bbb"); 201 CodeEntry entry2(i::Logger::FUNCTION_TAG, "bbb");
260 CodeEntry* e1_e2_path[] = {&entry1, &entry2}; 202 CodeEntry* e2_e1_path[] = {&entry2, &entry1};
261 Vector<CodeEntry*> e1_e2_path_vec( 203 Vector<CodeEntry*> e2_e1_path_vec(e2_e1_path,
262 e1_e2_path, sizeof(e1_e2_path) / sizeof(e1_e2_path[0])); 204 sizeof(e2_e1_path) / sizeof(e2_e1_path[0]));
263 205
264 ProfileTree flat_tree; 206 ProfileTree flat_tree;
265 ProfileTreeTestHelper flat_helper(&flat_tree); 207 ProfileTreeTestHelper flat_helper(&flat_tree);
266 flat_tree.AddPathFromStart(e1_path_vec); 208 flat_tree.AddPathFromEnd(e1_path_vec);
267 flat_tree.AddPathFromStart(e1_path_vec); 209 flat_tree.AddPathFromEnd(e1_path_vec);
268 flat_tree.AddPathFromStart(e1_e2_path_vec); 210 flat_tree.AddPathFromEnd(e2_e1_path_vec);
269 flat_tree.AddPathFromStart(e1_e2_path_vec); 211 flat_tree.AddPathFromEnd(e2_e1_path_vec);
270 flat_tree.AddPathFromStart(e1_e2_path_vec); 212 flat_tree.AddPathFromEnd(e2_e1_path_vec);
271 // Results in {root,0,0} -> {entry1,0,2} -> {entry2,0,3} 213 // Results in {root,0,0} -> {entry1,0,2} -> {entry2,0,3}
272 CHECK_EQ(0u, flat_tree.root()->self_ticks()); 214 CHECK_EQ(0u, flat_tree.root()->self_ticks());
273 node1 = flat_helper.Walk(&entry1); 215 node1 = flat_helper.Walk(&entry1);
274 CHECK(node1); 216 CHECK(node1);
275 CHECK_EQ(2u, node1->self_ticks()); 217 CHECK_EQ(2u, node1->self_ticks());
276 ProfileNode* node2 = flat_helper.Walk(&entry1, &entry2); 218 ProfileNode* node2 = flat_helper.Walk(&entry1, &entry2);
277 CHECK(node2); 219 CHECK(node2);
278 CHECK_EQ(3u, node2->self_ticks()); 220 CHECK_EQ(3u, node2->self_ticks());
279 // Must calculate {root,5,0} -> {entry1,5,2} -> {entry2,3,3} 221 // Must calculate {root,5,0} -> {entry1,5,2} -> {entry2,3,3}
280 CHECK_EQ(0u, flat_tree.root()->self_ticks()); 222 CHECK_EQ(0u, flat_tree.root()->self_ticks());
281 CHECK_EQ(2u, node1->self_ticks()); 223 CHECK_EQ(2u, node1->self_ticks());
282 224
283 CodeEntry* e2_path[] = {&entry2}; 225 CodeEntry* e2_path[] = {&entry2};
284 Vector<CodeEntry*> e2_path_vec( 226 Vector<CodeEntry*> e2_path_vec(
285 e2_path, sizeof(e2_path) / sizeof(e2_path[0])); 227 e2_path, sizeof(e2_path) / sizeof(e2_path[0]));
286 CodeEntry entry3(i::Logger::FUNCTION_TAG, "ccc"); 228 CodeEntry entry3(i::Logger::FUNCTION_TAG, "ccc");
287 CodeEntry* e3_path[] = {&entry3}; 229 CodeEntry* e3_path[] = {&entry3};
288 Vector<CodeEntry*> e3_path_vec( 230 Vector<CodeEntry*> e3_path_vec(
289 e3_path, sizeof(e3_path) / sizeof(e3_path[0])); 231 e3_path, sizeof(e3_path) / sizeof(e3_path[0]));
290 232
291 ProfileTree wide_tree; 233 ProfileTree wide_tree;
292 ProfileTreeTestHelper wide_helper(&wide_tree); 234 ProfileTreeTestHelper wide_helper(&wide_tree);
293 wide_tree.AddPathFromStart(e1_path_vec); 235 wide_tree.AddPathFromEnd(e1_path_vec);
294 wide_tree.AddPathFromStart(e1_path_vec); 236 wide_tree.AddPathFromEnd(e1_path_vec);
295 wide_tree.AddPathFromStart(e1_e2_path_vec); 237 wide_tree.AddPathFromEnd(e2_e1_path_vec);
296 wide_tree.AddPathFromStart(e2_path_vec); 238 wide_tree.AddPathFromEnd(e2_path_vec);
297 wide_tree.AddPathFromStart(e2_path_vec); 239 wide_tree.AddPathFromEnd(e2_path_vec);
298 wide_tree.AddPathFromStart(e2_path_vec); 240 wide_tree.AddPathFromEnd(e2_path_vec);
299 wide_tree.AddPathFromStart(e3_path_vec); 241 wide_tree.AddPathFromEnd(e3_path_vec);
300 wide_tree.AddPathFromStart(e3_path_vec); 242 wide_tree.AddPathFromEnd(e3_path_vec);
301 wide_tree.AddPathFromStart(e3_path_vec); 243 wide_tree.AddPathFromEnd(e3_path_vec);
302 wide_tree.AddPathFromStart(e3_path_vec); 244 wide_tree.AddPathFromEnd(e3_path_vec);
303 // Results in -> {entry1,0,2} -> {entry2,0,1} 245 // Results in -> {entry1,0,2} -> {entry2,0,1}
304 // {root,0,0} -> {entry2,0,3} 246 // {root,0,0} -> {entry2,0,3}
305 // -> {entry3,0,4} 247 // -> {entry3,0,4}
306 CHECK_EQ(0u, wide_tree.root()->self_ticks()); 248 CHECK_EQ(0u, wide_tree.root()->self_ticks());
307 node1 = wide_helper.Walk(&entry1); 249 node1 = wide_helper.Walk(&entry1);
308 CHECK(node1); 250 CHECK(node1);
309 CHECK_EQ(2u, node1->self_ticks()); 251 CHECK_EQ(2u, node1->self_ticks());
310 ProfileNode* node1_2 = wide_helper.Walk(&entry1, &entry2); 252 ProfileNode* node1_2 = wide_helper.Walk(&entry1, &entry2);
311 CHECK(node1_2); 253 CHECK(node1_2);
312 CHECK_EQ(1u, node1_2->self_ticks()); 254 CHECK_EQ(1u, node1_2->self_ticks());
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
767 CHECK(const_cast<v8::CpuProfileNode*>(current)); 709 CHECK(const_cast<v8::CpuProfileNode*>(current));
768 710
769 current = PickChild(current, "TryFinally"); 711 current = PickChild(current, "TryFinally");
770 CHECK(const_cast<v8::CpuProfileNode*>(current)); 712 CHECK(const_cast<v8::CpuProfileNode*>(current));
771 CHECK(!strcmp("TryFinallyStatement", current->GetBailoutReason())); 713 CHECK(!strcmp("TryFinallyStatement", current->GetBailoutReason()));
772 714
773 current = PickChild(current, "TryCatch"); 715 current = PickChild(current, "TryCatch");
774 CHECK(const_cast<v8::CpuProfileNode*>(current)); 716 CHECK(const_cast<v8::CpuProfileNode*>(current));
775 CHECK(!strcmp("TryCatchStatement", current->GetBailoutReason())); 717 CHECK(!strcmp("TryCatchStatement", current->GetBailoutReason()));
776 } 718 }
OLDNEW
« no previous file with comments | « src/profile-generator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698