fschneider@chromium.org | 086aac6 | 2010-03-17 13:18:24 +0000 | [diff] [blame] | 1 | // Copyright 2010 the V8 project authors. All rights reserved. |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 2 | // Redistribution and use in source and binary forms, with or without |
| 3 | // modification, are permitted provided that the following conditions are |
| 4 | // met: |
| 5 | // |
| 6 | // * Redistributions of source code must retain the above copyright |
| 7 | // notice, this list of conditions and the following disclaimer. |
| 8 | // * Redistributions in binary form must reproduce the above |
| 9 | // copyright notice, this list of conditions and the following |
| 10 | // disclaimer in the documentation and/or other materials provided |
| 11 | // with the distribution. |
| 12 | // * Neither the name of Google Inc. nor the names of its |
| 13 | // contributors may be used to endorse or promote products derived |
| 14 | // from this software without specific prior written permission. |
| 15 | // |
| 16 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 20 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 21 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
fschneider@chromium.org | 086aac6 | 2010-03-17 13:18:24 +0000 | [diff] [blame] | 27 | // |
| 28 | // Tests of profiles generator and utilities. |
| 29 | |
ulan@chromium.org | 57ff881 | 2013-05-10 08:16:55 +0000 | [diff] [blame^] | 30 | // TODO(dcarney): remove |
| 31 | #define V8_ALLOW_ACCESS_TO_PERSISTENT_IMPLICIT |
| 32 | |
fschneider@chromium.org | 086aac6 | 2010-03-17 13:18:24 +0000 | [diff] [blame] | 33 | #include "v8.h" |
| 34 | #include "profile-generator-inl.h" |
| 35 | #include "cctest.h" |
sgjesse@chromium.org | 82dbbab | 2010-06-02 08:57:44 +0000 | [diff] [blame] | 36 | #include "../include/v8-profiler.h" |
fschneider@chromium.org | 086aac6 | 2010-03-17 13:18:24 +0000 | [diff] [blame] | 37 | |
fschneider@chromium.org | 086aac6 | 2010-03-17 13:18:24 +0000 | [diff] [blame] | 38 | using i::CodeEntry; |
| 39 | using i::CodeMap; |
lrn@chromium.org | 25156de | 2010-04-06 13:10:27 +0000 | [diff] [blame] | 40 | using i::CpuProfile; |
sgjesse@chromium.org | 82dbbab | 2010-06-02 08:57:44 +0000 | [diff] [blame] | 41 | using i::CpuProfiler; |
whesse@chromium.org | cec079d | 2010-03-22 14:44:04 +0000 | [diff] [blame] | 42 | using i::CpuProfilesCollection; |
fschneider@chromium.org | 086aac6 | 2010-03-17 13:18:24 +0000 | [diff] [blame] | 43 | using i::ProfileNode; |
| 44 | using i::ProfileTree; |
whesse@chromium.org | cec079d | 2010-03-22 14:44:04 +0000 | [diff] [blame] | 45 | using i::ProfileGenerator; |
ricow@chromium.org | c9c8082 | 2010-04-21 08:22:37 +0000 | [diff] [blame] | 46 | using i::SampleRateCalculator; |
whesse@chromium.org | cec079d | 2010-03-22 14:44:04 +0000 | [diff] [blame] | 47 | using i::TickSample; |
erik.corry@gmail.com | 9dfbea4 | 2010-05-21 12:58:28 +0000 | [diff] [blame] | 48 | using i::TokenEnumerator; |
fschneider@chromium.org | 086aac6 | 2010-03-17 13:18:24 +0000 | [diff] [blame] | 49 | using i::Vector; |
| 50 | |
| 51 | |
erik.corry@gmail.com | 9dfbea4 | 2010-05-21 12:58:28 +0000 | [diff] [blame] | 52 | namespace v8 { |
| 53 | namespace internal { |
| 54 | |
| 55 | class TokenEnumeratorTester { |
| 56 | public: |
| 57 | static i::List<bool>* token_removed(TokenEnumerator* te) { |
| 58 | return &te->token_removed_; |
| 59 | } |
| 60 | }; |
| 61 | |
| 62 | } } // namespace v8::internal |
| 63 | |
| 64 | TEST(TokenEnumerator) { |
| 65 | TokenEnumerator te; |
vegorov@chromium.org | 2356e6f | 2010-06-09 09:38:56 +0000 | [diff] [blame] | 66 | CHECK_EQ(TokenEnumerator::kNoSecurityToken, te.GetTokenId(NULL)); |
svenpanne@chromium.org | 2bda543 | 2013-03-15 12:39:50 +0000 | [diff] [blame] | 67 | v8::HandleScope hs(v8::Isolate::GetCurrent()); |
ricow@chromium.org | 55ee807 | 2011-09-08 16:33:10 +0000 | [diff] [blame] | 68 | v8::Local<v8::String> token1(v8::String::New("1x")); |
erik.corry@gmail.com | 9dfbea4 | 2010-05-21 12:58:28 +0000 | [diff] [blame] | 69 | CHECK_EQ(0, te.GetTokenId(*v8::Utils::OpenHandle(*token1))); |
| 70 | CHECK_EQ(0, te.GetTokenId(*v8::Utils::OpenHandle(*token1))); |
ricow@chromium.org | 55ee807 | 2011-09-08 16:33:10 +0000 | [diff] [blame] | 71 | v8::Local<v8::String> token2(v8::String::New("2x")); |
erik.corry@gmail.com | 9dfbea4 | 2010-05-21 12:58:28 +0000 | [diff] [blame] | 72 | CHECK_EQ(1, te.GetTokenId(*v8::Utils::OpenHandle(*token2))); |
| 73 | CHECK_EQ(1, te.GetTokenId(*v8::Utils::OpenHandle(*token2))); |
| 74 | CHECK_EQ(0, te.GetTokenId(*v8::Utils::OpenHandle(*token1))); |
| 75 | { |
svenpanne@chromium.org | 2bda543 | 2013-03-15 12:39:50 +0000 | [diff] [blame] | 76 | v8::HandleScope hs(v8::Isolate::GetCurrent()); |
ricow@chromium.org | 55ee807 | 2011-09-08 16:33:10 +0000 | [diff] [blame] | 77 | v8::Local<v8::String> token3(v8::String::New("3x")); |
erik.corry@gmail.com | 9dfbea4 | 2010-05-21 12:58:28 +0000 | [diff] [blame] | 78 | CHECK_EQ(2, te.GetTokenId(*v8::Utils::OpenHandle(*token3))); |
| 79 | CHECK_EQ(1, te.GetTokenId(*v8::Utils::OpenHandle(*token2))); |
| 80 | CHECK_EQ(0, te.GetTokenId(*v8::Utils::OpenHandle(*token1))); |
| 81 | } |
| 82 | CHECK(!i::TokenEnumeratorTester::token_removed(&te)->at(2)); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 83 | HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); |
erik.corry@gmail.com | 9dfbea4 | 2010-05-21 12:58:28 +0000 | [diff] [blame] | 84 | CHECK(i::TokenEnumeratorTester::token_removed(&te)->at(2)); |
| 85 | CHECK_EQ(1, te.GetTokenId(*v8::Utils::OpenHandle(*token2))); |
| 86 | CHECK_EQ(0, te.GetTokenId(*v8::Utils::OpenHandle(*token1))); |
| 87 | } |
| 88 | |
| 89 | |
fschneider@chromium.org | 086aac6 | 2010-03-17 13:18:24 +0000 | [diff] [blame] | 90 | TEST(ProfileNodeFindOrAddChild) { |
mstarzinger@chromium.org | f705b50 | 2013-04-04 11:38:09 +0000 | [diff] [blame] | 91 | ProfileTree tree; |
| 92 | ProfileNode node(&tree, NULL); |
vegorov@chromium.org | 2356e6f | 2010-06-09 09:38:56 +0000 | [diff] [blame] | 93 | CodeEntry entry1(i::Logger::FUNCTION_TAG, "", "aaa", "", 0, |
| 94 | TokenEnumerator::kNoSecurityToken); |
fschneider@chromium.org | 086aac6 | 2010-03-17 13:18:24 +0000 | [diff] [blame] | 95 | ProfileNode* childNode1 = node.FindOrAddChild(&entry1); |
| 96 | CHECK_NE(NULL, childNode1); |
| 97 | CHECK_EQ(childNode1, node.FindOrAddChild(&entry1)); |
vegorov@chromium.org | 2356e6f | 2010-06-09 09:38:56 +0000 | [diff] [blame] | 98 | CodeEntry entry2(i::Logger::FUNCTION_TAG, "", "bbb", "", 0, |
| 99 | TokenEnumerator::kNoSecurityToken); |
fschneider@chromium.org | 086aac6 | 2010-03-17 13:18:24 +0000 | [diff] [blame] | 100 | ProfileNode* childNode2 = node.FindOrAddChild(&entry2); |
| 101 | CHECK_NE(NULL, childNode2); |
| 102 | CHECK_NE(childNode1, childNode2); |
| 103 | CHECK_EQ(childNode1, node.FindOrAddChild(&entry1)); |
| 104 | CHECK_EQ(childNode2, node.FindOrAddChild(&entry2)); |
vegorov@chromium.org | 2356e6f | 2010-06-09 09:38:56 +0000 | [diff] [blame] | 105 | CodeEntry entry3(i::Logger::FUNCTION_TAG, "", "ccc", "", 0, |
| 106 | TokenEnumerator::kNoSecurityToken); |
fschneider@chromium.org | 086aac6 | 2010-03-17 13:18:24 +0000 | [diff] [blame] | 107 | ProfileNode* childNode3 = node.FindOrAddChild(&entry3); |
| 108 | CHECK_NE(NULL, childNode3); |
| 109 | CHECK_NE(childNode1, childNode3); |
| 110 | CHECK_NE(childNode2, childNode3); |
| 111 | CHECK_EQ(childNode1, node.FindOrAddChild(&entry1)); |
| 112 | CHECK_EQ(childNode2, node.FindOrAddChild(&entry2)); |
| 113 | CHECK_EQ(childNode3, node.FindOrAddChild(&entry3)); |
| 114 | } |
| 115 | |
| 116 | |
fschneider@chromium.org | c20610a | 2010-09-22 09:44:58 +0000 | [diff] [blame] | 117 | TEST(ProfileNodeFindOrAddChildForSameFunction) { |
| 118 | const char* empty = ""; |
| 119 | const char* aaa = "aaa"; |
mstarzinger@chromium.org | f705b50 | 2013-04-04 11:38:09 +0000 | [diff] [blame] | 120 | ProfileTree tree; |
| 121 | ProfileNode node(&tree, NULL); |
fschneider@chromium.org | c20610a | 2010-09-22 09:44:58 +0000 | [diff] [blame] | 122 | CodeEntry entry1(i::Logger::FUNCTION_TAG, empty, aaa, empty, 0, |
| 123 | TokenEnumerator::kNoSecurityToken); |
| 124 | ProfileNode* childNode1 = node.FindOrAddChild(&entry1); |
| 125 | CHECK_NE(NULL, childNode1); |
| 126 | CHECK_EQ(childNode1, node.FindOrAddChild(&entry1)); |
| 127 | // The same function again. |
| 128 | CodeEntry entry2(i::Logger::FUNCTION_TAG, empty, aaa, empty, 0, |
| 129 | TokenEnumerator::kNoSecurityToken); |
| 130 | CHECK_EQ(childNode1, node.FindOrAddChild(&entry2)); |
| 131 | // Now with a different security token. |
| 132 | CodeEntry entry3(i::Logger::FUNCTION_TAG, empty, aaa, empty, 0, |
| 133 | TokenEnumerator::kNoSecurityToken + 1); |
| 134 | CHECK_EQ(childNode1, node.FindOrAddChild(&entry3)); |
| 135 | } |
| 136 | |
| 137 | |
fschneider@chromium.org | 086aac6 | 2010-03-17 13:18:24 +0000 | [diff] [blame] | 138 | namespace { |
| 139 | |
| 140 | class ProfileTreeTestHelper { |
| 141 | public: |
lrn@chromium.org | 25156de | 2010-04-06 13:10:27 +0000 | [diff] [blame] | 142 | explicit ProfileTreeTestHelper(const ProfileTree* tree) |
fschneider@chromium.org | 086aac6 | 2010-03-17 13:18:24 +0000 | [diff] [blame] | 143 | : tree_(tree) { } |
| 144 | |
| 145 | ProfileNode* Walk(CodeEntry* entry1, |
| 146 | CodeEntry* entry2 = NULL, |
| 147 | CodeEntry* entry3 = NULL) { |
| 148 | ProfileNode* node = tree_->root(); |
| 149 | node = node->FindChild(entry1); |
| 150 | if (node == NULL) return NULL; |
| 151 | if (entry2 != NULL) { |
| 152 | node = node->FindChild(entry2); |
| 153 | if (node == NULL) return NULL; |
| 154 | } |
| 155 | if (entry3 != NULL) { |
| 156 | node = node->FindChild(entry3); |
| 157 | } |
| 158 | return node; |
| 159 | } |
| 160 | |
| 161 | private: |
lrn@chromium.org | 25156de | 2010-04-06 13:10:27 +0000 | [diff] [blame] | 162 | const ProfileTree* tree_; |
fschneider@chromium.org | 086aac6 | 2010-03-17 13:18:24 +0000 | [diff] [blame] | 163 | }; |
| 164 | |
| 165 | } // namespace |
| 166 | |
| 167 | TEST(ProfileTreeAddPathFromStart) { |
vegorov@chromium.org | 2356e6f | 2010-06-09 09:38:56 +0000 | [diff] [blame] | 168 | CodeEntry entry1(i::Logger::FUNCTION_TAG, "", "aaa", "", 0, |
| 169 | TokenEnumerator::kNoSecurityToken); |
| 170 | CodeEntry entry2(i::Logger::FUNCTION_TAG, "", "bbb", "", 0, |
| 171 | TokenEnumerator::kNoSecurityToken); |
| 172 | CodeEntry entry3(i::Logger::FUNCTION_TAG, "", "ccc", "", 0, |
| 173 | TokenEnumerator::kNoSecurityToken); |
fschneider@chromium.org | 086aac6 | 2010-03-17 13:18:24 +0000 | [diff] [blame] | 174 | ProfileTree tree; |
| 175 | ProfileTreeTestHelper helper(&tree); |
| 176 | CHECK_EQ(NULL, helper.Walk(&entry1)); |
| 177 | CHECK_EQ(NULL, helper.Walk(&entry2)); |
| 178 | CHECK_EQ(NULL, helper.Walk(&entry3)); |
| 179 | |
| 180 | CodeEntry* path[] = {NULL, &entry1, NULL, &entry2, NULL, NULL, &entry3, NULL}; |
| 181 | Vector<CodeEntry*> path_vec(path, sizeof(path) / sizeof(path[0])); |
| 182 | tree.AddPathFromStart(path_vec); |
| 183 | CHECK_EQ(NULL, helper.Walk(&entry2)); |
| 184 | CHECK_EQ(NULL, helper.Walk(&entry3)); |
| 185 | ProfileNode* node1 = helper.Walk(&entry1); |
| 186 | CHECK_NE(NULL, node1); |
| 187 | CHECK_EQ(0, node1->total_ticks()); |
| 188 | CHECK_EQ(0, node1->self_ticks()); |
| 189 | CHECK_EQ(NULL, helper.Walk(&entry1, &entry1)); |
| 190 | CHECK_EQ(NULL, helper.Walk(&entry1, &entry3)); |
| 191 | ProfileNode* node2 = helper.Walk(&entry1, &entry2); |
| 192 | CHECK_NE(NULL, node2); |
| 193 | CHECK_NE(node1, node2); |
| 194 | CHECK_EQ(0, node2->total_ticks()); |
| 195 | CHECK_EQ(0, node2->self_ticks()); |
| 196 | CHECK_EQ(NULL, helper.Walk(&entry1, &entry2, &entry1)); |
| 197 | CHECK_EQ(NULL, helper.Walk(&entry1, &entry2, &entry2)); |
| 198 | ProfileNode* node3 = helper.Walk(&entry1, &entry2, &entry3); |
| 199 | CHECK_NE(NULL, node3); |
| 200 | CHECK_NE(node1, node3); |
| 201 | CHECK_NE(node2, node3); |
| 202 | CHECK_EQ(0, node3->total_ticks()); |
| 203 | CHECK_EQ(1, node3->self_ticks()); |
| 204 | |
| 205 | tree.AddPathFromStart(path_vec); |
| 206 | CHECK_EQ(node1, helper.Walk(&entry1)); |
| 207 | CHECK_EQ(node2, helper.Walk(&entry1, &entry2)); |
| 208 | CHECK_EQ(node3, helper.Walk(&entry1, &entry2, &entry3)); |
| 209 | CHECK_EQ(0, node1->total_ticks()); |
| 210 | CHECK_EQ(0, node1->self_ticks()); |
| 211 | CHECK_EQ(0, node2->total_ticks()); |
| 212 | CHECK_EQ(0, node2->self_ticks()); |
| 213 | CHECK_EQ(0, node3->total_ticks()); |
| 214 | CHECK_EQ(2, node3->self_ticks()); |
| 215 | |
| 216 | CodeEntry* path2[] = {&entry1, &entry2, &entry2}; |
| 217 | Vector<CodeEntry*> path2_vec(path2, sizeof(path2) / sizeof(path2[0])); |
| 218 | tree.AddPathFromStart(path2_vec); |
| 219 | CHECK_EQ(NULL, helper.Walk(&entry2)); |
| 220 | CHECK_EQ(NULL, helper.Walk(&entry3)); |
| 221 | CHECK_EQ(node1, helper.Walk(&entry1)); |
| 222 | CHECK_EQ(NULL, helper.Walk(&entry1, &entry1)); |
| 223 | CHECK_EQ(NULL, helper.Walk(&entry1, &entry3)); |
| 224 | CHECK_EQ(node2, helper.Walk(&entry1, &entry2)); |
| 225 | CHECK_EQ(NULL, helper.Walk(&entry1, &entry2, &entry1)); |
| 226 | CHECK_EQ(node3, helper.Walk(&entry1, &entry2, &entry3)); |
| 227 | CHECK_EQ(0, node3->total_ticks()); |
| 228 | CHECK_EQ(2, node3->self_ticks()); |
| 229 | ProfileNode* node4 = helper.Walk(&entry1, &entry2, &entry2); |
| 230 | CHECK_NE(NULL, node4); |
| 231 | CHECK_NE(node3, node4); |
| 232 | CHECK_EQ(0, node4->total_ticks()); |
| 233 | CHECK_EQ(1, node4->self_ticks()); |
| 234 | } |
| 235 | |
| 236 | |
| 237 | TEST(ProfileTreeAddPathFromEnd) { |
vegorov@chromium.org | 2356e6f | 2010-06-09 09:38:56 +0000 | [diff] [blame] | 238 | CodeEntry entry1(i::Logger::FUNCTION_TAG, "", "aaa", "", 0, |
| 239 | TokenEnumerator::kNoSecurityToken); |
| 240 | CodeEntry entry2(i::Logger::FUNCTION_TAG, "", "bbb", "", 0, |
| 241 | TokenEnumerator::kNoSecurityToken); |
| 242 | CodeEntry entry3(i::Logger::FUNCTION_TAG, "", "ccc", "", 0, |
| 243 | TokenEnumerator::kNoSecurityToken); |
fschneider@chromium.org | 086aac6 | 2010-03-17 13:18:24 +0000 | [diff] [blame] | 244 | ProfileTree tree; |
| 245 | ProfileTreeTestHelper helper(&tree); |
| 246 | CHECK_EQ(NULL, helper.Walk(&entry1)); |
| 247 | CHECK_EQ(NULL, helper.Walk(&entry2)); |
| 248 | CHECK_EQ(NULL, helper.Walk(&entry3)); |
| 249 | |
| 250 | CodeEntry* path[] = {NULL, &entry3, NULL, &entry2, NULL, NULL, &entry1, NULL}; |
| 251 | Vector<CodeEntry*> path_vec(path, sizeof(path) / sizeof(path[0])); |
| 252 | tree.AddPathFromEnd(path_vec); |
| 253 | CHECK_EQ(NULL, helper.Walk(&entry2)); |
| 254 | CHECK_EQ(NULL, helper.Walk(&entry3)); |
| 255 | ProfileNode* node1 = helper.Walk(&entry1); |
| 256 | CHECK_NE(NULL, node1); |
| 257 | CHECK_EQ(0, node1->total_ticks()); |
| 258 | CHECK_EQ(0, node1->self_ticks()); |
| 259 | CHECK_EQ(NULL, helper.Walk(&entry1, &entry1)); |
| 260 | CHECK_EQ(NULL, helper.Walk(&entry1, &entry3)); |
| 261 | ProfileNode* node2 = helper.Walk(&entry1, &entry2); |
| 262 | CHECK_NE(NULL, node2); |
| 263 | CHECK_NE(node1, node2); |
| 264 | CHECK_EQ(0, node2->total_ticks()); |
| 265 | CHECK_EQ(0, node2->self_ticks()); |
| 266 | CHECK_EQ(NULL, helper.Walk(&entry1, &entry2, &entry1)); |
| 267 | CHECK_EQ(NULL, helper.Walk(&entry1, &entry2, &entry2)); |
| 268 | ProfileNode* node3 = helper.Walk(&entry1, &entry2, &entry3); |
| 269 | CHECK_NE(NULL, node3); |
| 270 | CHECK_NE(node1, node3); |
| 271 | CHECK_NE(node2, node3); |
| 272 | CHECK_EQ(0, node3->total_ticks()); |
| 273 | CHECK_EQ(1, node3->self_ticks()); |
| 274 | |
| 275 | tree.AddPathFromEnd(path_vec); |
| 276 | CHECK_EQ(node1, helper.Walk(&entry1)); |
| 277 | CHECK_EQ(node2, helper.Walk(&entry1, &entry2)); |
| 278 | CHECK_EQ(node3, helper.Walk(&entry1, &entry2, &entry3)); |
| 279 | CHECK_EQ(0, node1->total_ticks()); |
| 280 | CHECK_EQ(0, node1->self_ticks()); |
| 281 | CHECK_EQ(0, node2->total_ticks()); |
| 282 | CHECK_EQ(0, node2->self_ticks()); |
| 283 | CHECK_EQ(0, node3->total_ticks()); |
| 284 | CHECK_EQ(2, node3->self_ticks()); |
| 285 | |
| 286 | CodeEntry* path2[] = {&entry2, &entry2, &entry1}; |
| 287 | Vector<CodeEntry*> path2_vec(path2, sizeof(path2) / sizeof(path2[0])); |
| 288 | tree.AddPathFromEnd(path2_vec); |
| 289 | CHECK_EQ(NULL, helper.Walk(&entry2)); |
| 290 | CHECK_EQ(NULL, helper.Walk(&entry3)); |
| 291 | CHECK_EQ(node1, helper.Walk(&entry1)); |
| 292 | CHECK_EQ(NULL, helper.Walk(&entry1, &entry1)); |
| 293 | CHECK_EQ(NULL, helper.Walk(&entry1, &entry3)); |
| 294 | CHECK_EQ(node2, helper.Walk(&entry1, &entry2)); |
| 295 | CHECK_EQ(NULL, helper.Walk(&entry1, &entry2, &entry1)); |
| 296 | CHECK_EQ(node3, helper.Walk(&entry1, &entry2, &entry3)); |
| 297 | CHECK_EQ(0, node3->total_ticks()); |
| 298 | CHECK_EQ(2, node3->self_ticks()); |
| 299 | ProfileNode* node4 = helper.Walk(&entry1, &entry2, &entry2); |
| 300 | CHECK_NE(NULL, node4); |
| 301 | CHECK_NE(node3, node4); |
| 302 | CHECK_EQ(0, node4->total_ticks()); |
| 303 | CHECK_EQ(1, node4->self_ticks()); |
| 304 | } |
| 305 | |
| 306 | |
| 307 | TEST(ProfileTreeCalculateTotalTicks) { |
| 308 | ProfileTree empty_tree; |
| 309 | CHECK_EQ(0, empty_tree.root()->total_ticks()); |
| 310 | CHECK_EQ(0, empty_tree.root()->self_ticks()); |
| 311 | empty_tree.CalculateTotalTicks(); |
| 312 | CHECK_EQ(0, empty_tree.root()->total_ticks()); |
| 313 | CHECK_EQ(0, empty_tree.root()->self_ticks()); |
| 314 | empty_tree.root()->IncrementSelfTicks(); |
| 315 | CHECK_EQ(0, empty_tree.root()->total_ticks()); |
| 316 | CHECK_EQ(1, empty_tree.root()->self_ticks()); |
| 317 | empty_tree.CalculateTotalTicks(); |
| 318 | CHECK_EQ(1, empty_tree.root()->total_ticks()); |
| 319 | CHECK_EQ(1, empty_tree.root()->self_ticks()); |
| 320 | |
vegorov@chromium.org | 2356e6f | 2010-06-09 09:38:56 +0000 | [diff] [blame] | 321 | CodeEntry entry1(i::Logger::FUNCTION_TAG, "", "aaa", "", 0, |
| 322 | TokenEnumerator::kNoSecurityToken); |
fschneider@chromium.org | 086aac6 | 2010-03-17 13:18:24 +0000 | [diff] [blame] | 323 | CodeEntry* e1_path[] = {&entry1}; |
| 324 | Vector<CodeEntry*> e1_path_vec( |
| 325 | e1_path, sizeof(e1_path) / sizeof(e1_path[0])); |
erik.corry@gmail.com | 9dfbea4 | 2010-05-21 12:58:28 +0000 | [diff] [blame] | 326 | |
| 327 | ProfileTree single_child_tree; |
| 328 | single_child_tree.AddPathFromStart(e1_path_vec); |
| 329 | single_child_tree.root()->IncrementSelfTicks(); |
| 330 | CHECK_EQ(0, single_child_tree.root()->total_ticks()); |
| 331 | CHECK_EQ(1, single_child_tree.root()->self_ticks()); |
| 332 | ProfileTreeTestHelper single_child_helper(&single_child_tree); |
| 333 | ProfileNode* node1 = single_child_helper.Walk(&entry1); |
| 334 | CHECK_NE(NULL, node1); |
| 335 | CHECK_EQ(0, node1->total_ticks()); |
| 336 | CHECK_EQ(1, node1->self_ticks()); |
| 337 | single_child_tree.CalculateTotalTicks(); |
| 338 | CHECK_EQ(2, single_child_tree.root()->total_ticks()); |
| 339 | CHECK_EQ(1, single_child_tree.root()->self_ticks()); |
| 340 | CHECK_EQ(1, node1->total_ticks()); |
| 341 | CHECK_EQ(1, node1->self_ticks()); |
| 342 | |
vegorov@chromium.org | 2356e6f | 2010-06-09 09:38:56 +0000 | [diff] [blame] | 343 | CodeEntry entry2(i::Logger::FUNCTION_TAG, "", "bbb", "", 0, |
| 344 | TokenEnumerator::kNoSecurityToken); |
fschneider@chromium.org | 086aac6 | 2010-03-17 13:18:24 +0000 | [diff] [blame] | 345 | CodeEntry* e1_e2_path[] = {&entry1, &entry2}; |
| 346 | Vector<CodeEntry*> e1_e2_path_vec( |
| 347 | e1_e2_path, sizeof(e1_e2_path) / sizeof(e1_e2_path[0])); |
| 348 | |
| 349 | ProfileTree flat_tree; |
| 350 | ProfileTreeTestHelper flat_helper(&flat_tree); |
| 351 | flat_tree.AddPathFromStart(e1_path_vec); |
| 352 | flat_tree.AddPathFromStart(e1_path_vec); |
| 353 | flat_tree.AddPathFromStart(e1_e2_path_vec); |
| 354 | flat_tree.AddPathFromStart(e1_e2_path_vec); |
| 355 | flat_tree.AddPathFromStart(e1_e2_path_vec); |
| 356 | // Results in {root,0,0} -> {entry1,0,2} -> {entry2,0,3} |
| 357 | CHECK_EQ(0, flat_tree.root()->total_ticks()); |
| 358 | CHECK_EQ(0, flat_tree.root()->self_ticks()); |
erik.corry@gmail.com | 9dfbea4 | 2010-05-21 12:58:28 +0000 | [diff] [blame] | 359 | node1 = flat_helper.Walk(&entry1); |
fschneider@chromium.org | 086aac6 | 2010-03-17 13:18:24 +0000 | [diff] [blame] | 360 | CHECK_NE(NULL, node1); |
| 361 | CHECK_EQ(0, node1->total_ticks()); |
| 362 | CHECK_EQ(2, node1->self_ticks()); |
| 363 | ProfileNode* node2 = flat_helper.Walk(&entry1, &entry2); |
| 364 | CHECK_NE(NULL, node2); |
| 365 | CHECK_EQ(0, node2->total_ticks()); |
| 366 | CHECK_EQ(3, node2->self_ticks()); |
| 367 | flat_tree.CalculateTotalTicks(); |
| 368 | // Must calculate {root,5,0} -> {entry1,5,2} -> {entry2,3,3} |
| 369 | CHECK_EQ(5, flat_tree.root()->total_ticks()); |
| 370 | CHECK_EQ(0, flat_tree.root()->self_ticks()); |
| 371 | CHECK_EQ(5, node1->total_ticks()); |
| 372 | CHECK_EQ(2, node1->self_ticks()); |
| 373 | CHECK_EQ(3, node2->total_ticks()); |
| 374 | CHECK_EQ(3, node2->self_ticks()); |
| 375 | |
| 376 | CodeEntry* e2_path[] = {&entry2}; |
| 377 | Vector<CodeEntry*> e2_path_vec( |
| 378 | e2_path, sizeof(e2_path) / sizeof(e2_path[0])); |
vegorov@chromium.org | 2356e6f | 2010-06-09 09:38:56 +0000 | [diff] [blame] | 379 | CodeEntry entry3(i::Logger::FUNCTION_TAG, "", "ccc", "", 0, |
| 380 | TokenEnumerator::kNoSecurityToken); |
fschneider@chromium.org | 086aac6 | 2010-03-17 13:18:24 +0000 | [diff] [blame] | 381 | CodeEntry* e3_path[] = {&entry3}; |
| 382 | Vector<CodeEntry*> e3_path_vec( |
| 383 | e3_path, sizeof(e3_path) / sizeof(e3_path[0])); |
| 384 | |
| 385 | ProfileTree wide_tree; |
| 386 | ProfileTreeTestHelper wide_helper(&wide_tree); |
| 387 | wide_tree.AddPathFromStart(e1_path_vec); |
| 388 | wide_tree.AddPathFromStart(e1_path_vec); |
| 389 | wide_tree.AddPathFromStart(e1_e2_path_vec); |
| 390 | wide_tree.AddPathFromStart(e2_path_vec); |
| 391 | wide_tree.AddPathFromStart(e2_path_vec); |
| 392 | wide_tree.AddPathFromStart(e2_path_vec); |
| 393 | wide_tree.AddPathFromStart(e3_path_vec); |
| 394 | wide_tree.AddPathFromStart(e3_path_vec); |
| 395 | wide_tree.AddPathFromStart(e3_path_vec); |
| 396 | wide_tree.AddPathFromStart(e3_path_vec); |
| 397 | // Results in -> {entry1,0,2} -> {entry2,0,1} |
| 398 | // {root,0,0} -> {entry2,0,3} |
| 399 | // -> {entry3,0,4} |
| 400 | CHECK_EQ(0, wide_tree.root()->total_ticks()); |
| 401 | CHECK_EQ(0, wide_tree.root()->self_ticks()); |
| 402 | node1 = wide_helper.Walk(&entry1); |
| 403 | CHECK_NE(NULL, node1); |
| 404 | CHECK_EQ(0, node1->total_ticks()); |
| 405 | CHECK_EQ(2, node1->self_ticks()); |
| 406 | ProfileNode* node1_2 = wide_helper.Walk(&entry1, &entry2); |
| 407 | CHECK_NE(NULL, node1_2); |
| 408 | CHECK_EQ(0, node1_2->total_ticks()); |
| 409 | CHECK_EQ(1, node1_2->self_ticks()); |
| 410 | node2 = wide_helper.Walk(&entry2); |
| 411 | CHECK_NE(NULL, node2); |
| 412 | CHECK_EQ(0, node2->total_ticks()); |
| 413 | CHECK_EQ(3, node2->self_ticks()); |
| 414 | ProfileNode* node3 = wide_helper.Walk(&entry3); |
| 415 | CHECK_NE(NULL, node3); |
| 416 | CHECK_EQ(0, node3->total_ticks()); |
| 417 | CHECK_EQ(4, node3->self_ticks()); |
| 418 | wide_tree.CalculateTotalTicks(); |
| 419 | // Calculates -> {entry1,3,2} -> {entry2,1,1} |
| 420 | // {root,10,0} -> {entry2,3,3} |
| 421 | // -> {entry3,4,4} |
| 422 | CHECK_EQ(10, wide_tree.root()->total_ticks()); |
| 423 | CHECK_EQ(0, wide_tree.root()->self_ticks()); |
| 424 | CHECK_EQ(3, node1->total_ticks()); |
| 425 | CHECK_EQ(2, node1->self_ticks()); |
| 426 | CHECK_EQ(1, node1_2->total_ticks()); |
| 427 | CHECK_EQ(1, node1_2->self_ticks()); |
| 428 | CHECK_EQ(3, node2->total_ticks()); |
| 429 | CHECK_EQ(3, node2->self_ticks()); |
| 430 | CHECK_EQ(4, node3->total_ticks()); |
| 431 | CHECK_EQ(4, node3->self_ticks()); |
| 432 | } |
| 433 | |
| 434 | |
erik.corry@gmail.com | 9dfbea4 | 2010-05-21 12:58:28 +0000 | [diff] [blame] | 435 | TEST(ProfileTreeFilteredClone) { |
| 436 | ProfileTree source_tree; |
| 437 | const int token0 = 0, token1 = 1, token2 = 2; |
| 438 | CodeEntry entry1(i::Logger::FUNCTION_TAG, "", "aaa", "", 0, token0); |
| 439 | CodeEntry entry2(i::Logger::FUNCTION_TAG, "", "bbb", "", 0, token1); |
| 440 | CodeEntry entry3(i::Logger::FUNCTION_TAG, "", "ccc", "", 0, token0); |
| 441 | CodeEntry entry4( |
| 442 | i::Logger::FUNCTION_TAG, "", "ddd", "", 0, |
vegorov@chromium.org | 2356e6f | 2010-06-09 09:38:56 +0000 | [diff] [blame] | 443 | TokenEnumerator::kInheritsSecurityToken); |
erik.corry@gmail.com | 9dfbea4 | 2010-05-21 12:58:28 +0000 | [diff] [blame] | 444 | |
| 445 | { |
| 446 | CodeEntry* e1_e2_path[] = {&entry1, &entry2}; |
| 447 | Vector<CodeEntry*> e1_e2_path_vec( |
| 448 | e1_e2_path, sizeof(e1_e2_path) / sizeof(e1_e2_path[0])); |
| 449 | source_tree.AddPathFromStart(e1_e2_path_vec); |
| 450 | CodeEntry* e2_e4_path[] = {&entry2, &entry4}; |
| 451 | Vector<CodeEntry*> e2_e4_path_vec( |
| 452 | e2_e4_path, sizeof(e2_e4_path) / sizeof(e2_e4_path[0])); |
| 453 | source_tree.AddPathFromStart(e2_e4_path_vec); |
| 454 | CodeEntry* e3_e1_path[] = {&entry3, &entry1}; |
| 455 | Vector<CodeEntry*> e3_e1_path_vec( |
| 456 | e3_e1_path, sizeof(e3_e1_path) / sizeof(e3_e1_path[0])); |
| 457 | source_tree.AddPathFromStart(e3_e1_path_vec); |
| 458 | CodeEntry* e3_e2_path[] = {&entry3, &entry2}; |
| 459 | Vector<CodeEntry*> e3_e2_path_vec( |
| 460 | e3_e2_path, sizeof(e3_e2_path) / sizeof(e3_e2_path[0])); |
| 461 | source_tree.AddPathFromStart(e3_e2_path_vec); |
| 462 | source_tree.CalculateTotalTicks(); |
| 463 | // Results in -> {entry1,0,1,0} -> {entry2,1,1,1} |
| 464 | // {root,0,4,-1} -> {entry2,0,1,1} -> {entry4,1,1,inherits} |
| 465 | // -> {entry3,0,2,0} -> {entry1,1,1,0} |
| 466 | // -> {entry2,1,1,1} |
| 467 | CHECK_EQ(4, source_tree.root()->total_ticks()); |
| 468 | CHECK_EQ(0, source_tree.root()->self_ticks()); |
| 469 | } |
| 470 | |
| 471 | { |
| 472 | ProfileTree token0_tree; |
| 473 | token0_tree.FilteredClone(&source_tree, token0); |
| 474 | // Should be -> {entry1,1,1,0} |
| 475 | // {root,1,4,-1} -> {entry3,1,2,0} -> {entry1,1,1,0} |
| 476 | // [self ticks from filtered nodes are attributed to their parents] |
| 477 | CHECK_EQ(4, token0_tree.root()->total_ticks()); |
| 478 | CHECK_EQ(1, token0_tree.root()->self_ticks()); |
| 479 | ProfileTreeTestHelper token0_helper(&token0_tree); |
| 480 | ProfileNode* node1 = token0_helper.Walk(&entry1); |
| 481 | CHECK_NE(NULL, node1); |
| 482 | CHECK_EQ(1, node1->total_ticks()); |
| 483 | CHECK_EQ(1, node1->self_ticks()); |
| 484 | CHECK_EQ(NULL, token0_helper.Walk(&entry2)); |
| 485 | ProfileNode* node3 = token0_helper.Walk(&entry3); |
| 486 | CHECK_NE(NULL, node3); |
| 487 | CHECK_EQ(2, node3->total_ticks()); |
| 488 | CHECK_EQ(1, node3->self_ticks()); |
| 489 | ProfileNode* node3_1 = token0_helper.Walk(&entry3, &entry1); |
| 490 | CHECK_NE(NULL, node3_1); |
| 491 | CHECK_EQ(1, node3_1->total_ticks()); |
| 492 | CHECK_EQ(1, node3_1->self_ticks()); |
| 493 | CHECK_EQ(NULL, token0_helper.Walk(&entry3, &entry2)); |
| 494 | } |
| 495 | |
| 496 | { |
| 497 | ProfileTree token1_tree; |
| 498 | token1_tree.FilteredClone(&source_tree, token1); |
| 499 | // Should be |
| 500 | // {root,1,4,-1} -> {entry2,2,3,1} -> {entry4,1,1,inherits} |
| 501 | // [child nodes referring to the same entry get merged and |
| 502 | // their self times summed up] |
| 503 | CHECK_EQ(4, token1_tree.root()->total_ticks()); |
| 504 | CHECK_EQ(1, token1_tree.root()->self_ticks()); |
| 505 | ProfileTreeTestHelper token1_helper(&token1_tree); |
| 506 | CHECK_EQ(NULL, token1_helper.Walk(&entry1)); |
| 507 | CHECK_EQ(NULL, token1_helper.Walk(&entry3)); |
| 508 | ProfileNode* node2 = token1_helper.Walk(&entry2); |
| 509 | CHECK_NE(NULL, node2); |
| 510 | CHECK_EQ(3, node2->total_ticks()); |
| 511 | CHECK_EQ(2, node2->self_ticks()); |
| 512 | ProfileNode* node2_4 = token1_helper.Walk(&entry2, &entry4); |
| 513 | CHECK_NE(NULL, node2_4); |
| 514 | CHECK_EQ(1, node2_4->total_ticks()); |
| 515 | CHECK_EQ(1, node2_4->self_ticks()); |
| 516 | } |
| 517 | |
| 518 | { |
| 519 | ProfileTree token2_tree; |
| 520 | token2_tree.FilteredClone(&source_tree, token2); |
| 521 | // Should be |
| 522 | // {root,4,4,-1} |
| 523 | // [no nodes, all ticks get migrated into root node] |
| 524 | CHECK_EQ(4, token2_tree.root()->total_ticks()); |
| 525 | CHECK_EQ(4, token2_tree.root()->self_ticks()); |
| 526 | ProfileTreeTestHelper token2_helper(&token2_tree); |
| 527 | CHECK_EQ(NULL, token2_helper.Walk(&entry1)); |
| 528 | CHECK_EQ(NULL, token2_helper.Walk(&entry2)); |
| 529 | CHECK_EQ(NULL, token2_helper.Walk(&entry3)); |
| 530 | } |
| 531 | } |
| 532 | |
| 533 | |
fschneider@chromium.org | 086aac6 | 2010-03-17 13:18:24 +0000 | [diff] [blame] | 534 | static inline i::Address ToAddress(int n) { |
| 535 | return reinterpret_cast<i::Address>(n); |
| 536 | } |
| 537 | |
| 538 | TEST(CodeMapAddCode) { |
| 539 | CodeMap code_map; |
vegorov@chromium.org | 2356e6f | 2010-06-09 09:38:56 +0000 | [diff] [blame] | 540 | CodeEntry entry1(i::Logger::FUNCTION_TAG, "", "aaa", "", 0, |
| 541 | TokenEnumerator::kNoSecurityToken); |
| 542 | CodeEntry entry2(i::Logger::FUNCTION_TAG, "", "bbb", "", 0, |
| 543 | TokenEnumerator::kNoSecurityToken); |
| 544 | CodeEntry entry3(i::Logger::FUNCTION_TAG, "", "ccc", "", 0, |
| 545 | TokenEnumerator::kNoSecurityToken); |
| 546 | CodeEntry entry4(i::Logger::FUNCTION_TAG, "", "ddd", "", 0, |
| 547 | TokenEnumerator::kNoSecurityToken); |
fschneider@chromium.org | 086aac6 | 2010-03-17 13:18:24 +0000 | [diff] [blame] | 548 | code_map.AddCode(ToAddress(0x1500), &entry1, 0x200); |
| 549 | code_map.AddCode(ToAddress(0x1700), &entry2, 0x100); |
| 550 | code_map.AddCode(ToAddress(0x1900), &entry3, 0x50); |
| 551 | code_map.AddCode(ToAddress(0x1950), &entry4, 0x10); |
| 552 | CHECK_EQ(NULL, code_map.FindEntry(0)); |
| 553 | CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0x1500 - 1))); |
| 554 | CHECK_EQ(&entry1, code_map.FindEntry(ToAddress(0x1500))); |
| 555 | CHECK_EQ(&entry1, code_map.FindEntry(ToAddress(0x1500 + 0x100))); |
| 556 | CHECK_EQ(&entry1, code_map.FindEntry(ToAddress(0x1500 + 0x200 - 1))); |
| 557 | CHECK_EQ(&entry2, code_map.FindEntry(ToAddress(0x1700))); |
| 558 | CHECK_EQ(&entry2, code_map.FindEntry(ToAddress(0x1700 + 0x50))); |
| 559 | CHECK_EQ(&entry2, code_map.FindEntry(ToAddress(0x1700 + 0x100 - 1))); |
| 560 | CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0x1700 + 0x100))); |
| 561 | CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0x1900 - 1))); |
| 562 | CHECK_EQ(&entry3, code_map.FindEntry(ToAddress(0x1900))); |
| 563 | CHECK_EQ(&entry3, code_map.FindEntry(ToAddress(0x1900 + 0x28))); |
| 564 | CHECK_EQ(&entry4, code_map.FindEntry(ToAddress(0x1950))); |
| 565 | CHECK_EQ(&entry4, code_map.FindEntry(ToAddress(0x1950 + 0x7))); |
| 566 | CHECK_EQ(&entry4, code_map.FindEntry(ToAddress(0x1950 + 0x10 - 1))); |
| 567 | CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0x1950 + 0x10))); |
| 568 | CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0xFFFFFFFF))); |
| 569 | } |
| 570 | |
| 571 | |
| 572 | TEST(CodeMapMoveAndDeleteCode) { |
| 573 | CodeMap code_map; |
vegorov@chromium.org | 2356e6f | 2010-06-09 09:38:56 +0000 | [diff] [blame] | 574 | CodeEntry entry1(i::Logger::FUNCTION_TAG, "", "aaa", "", 0, |
| 575 | TokenEnumerator::kNoSecurityToken); |
| 576 | CodeEntry entry2(i::Logger::FUNCTION_TAG, "", "bbb", "", 0, |
| 577 | TokenEnumerator::kNoSecurityToken); |
fschneider@chromium.org | 086aac6 | 2010-03-17 13:18:24 +0000 | [diff] [blame] | 578 | code_map.AddCode(ToAddress(0x1500), &entry1, 0x200); |
| 579 | code_map.AddCode(ToAddress(0x1700), &entry2, 0x100); |
| 580 | CHECK_EQ(&entry1, code_map.FindEntry(ToAddress(0x1500))); |
| 581 | CHECK_EQ(&entry2, code_map.FindEntry(ToAddress(0x1700))); |
lrn@chromium.org | 34e6078 | 2011-09-15 07:25:40 +0000 | [diff] [blame] | 582 | code_map.MoveCode(ToAddress(0x1500), ToAddress(0x1700)); // Deprecate bbb. |
fschneider@chromium.org | 086aac6 | 2010-03-17 13:18:24 +0000 | [diff] [blame] | 583 | CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0x1500))); |
lrn@chromium.org | 34e6078 | 2011-09-15 07:25:40 +0000 | [diff] [blame] | 584 | CHECK_EQ(&entry1, code_map.FindEntry(ToAddress(0x1700))); |
| 585 | CodeEntry entry3(i::Logger::FUNCTION_TAG, "", "ccc", "", 0, |
| 586 | TokenEnumerator::kNoSecurityToken); |
| 587 | code_map.AddCode(ToAddress(0x1750), &entry3, 0x100); |
fschneider@chromium.org | 086aac6 | 2010-03-17 13:18:24 +0000 | [diff] [blame] | 588 | CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0x1700))); |
lrn@chromium.org | 34e6078 | 2011-09-15 07:25:40 +0000 | [diff] [blame] | 589 | CHECK_EQ(&entry3, code_map.FindEntry(ToAddress(0x1750))); |
fschneider@chromium.org | 086aac6 | 2010-03-17 13:18:24 +0000 | [diff] [blame] | 590 | } |
whesse@chromium.org | cec079d | 2010-03-22 14:44:04 +0000 | [diff] [blame] | 591 | |
| 592 | |
ager@chromium.org | 357bf65 | 2010-04-12 11:30:10 +0000 | [diff] [blame] | 593 | namespace { |
| 594 | |
| 595 | class TestSetup { |
| 596 | public: |
| 597 | TestSetup() |
| 598 | : old_flag_prof_browser_mode_(i::FLAG_prof_browser_mode) { |
| 599 | i::FLAG_prof_browser_mode = false; |
| 600 | } |
| 601 | |
| 602 | ~TestSetup() { |
| 603 | i::FLAG_prof_browser_mode = old_flag_prof_browser_mode_; |
| 604 | } |
| 605 | |
| 606 | private: |
| 607 | bool old_flag_prof_browser_mode_; |
| 608 | }; |
| 609 | |
| 610 | } // namespace |
| 611 | |
whesse@chromium.org | cec079d | 2010-03-22 14:44:04 +0000 | [diff] [blame] | 612 | TEST(RecordTickSample) { |
ager@chromium.org | 357bf65 | 2010-04-12 11:30:10 +0000 | [diff] [blame] | 613 | TestSetup test_setup; |
whesse@chromium.org | cec079d | 2010-03-22 14:44:04 +0000 | [diff] [blame] | 614 | CpuProfilesCollection profiles; |
mstarzinger@chromium.org | f705b50 | 2013-04-04 11:38:09 +0000 | [diff] [blame] | 615 | profiles.StartProfiling("", 1, false); |
whesse@chromium.org | cec079d | 2010-03-22 14:44:04 +0000 | [diff] [blame] | 616 | ProfileGenerator generator(&profiles); |
danno@chromium.org | ca29dd8 | 2013-04-26 11:59:48 +0000 | [diff] [blame] | 617 | CodeEntry* entry1 = profiles.NewCodeEntry(i::Logger::FUNCTION_TAG, "aaa"); |
| 618 | CodeEntry* entry2 = profiles.NewCodeEntry(i::Logger::FUNCTION_TAG, "bbb"); |
| 619 | CodeEntry* entry3 = profiles.NewCodeEntry(i::Logger::FUNCTION_TAG, "ccc"); |
whesse@chromium.org | cec079d | 2010-03-22 14:44:04 +0000 | [diff] [blame] | 620 | generator.code_map()->AddCode(ToAddress(0x1500), entry1, 0x200); |
| 621 | generator.code_map()->AddCode(ToAddress(0x1700), entry2, 0x100); |
| 622 | generator.code_map()->AddCode(ToAddress(0x1900), entry3, 0x50); |
| 623 | |
whesse@chromium.org | cec079d | 2010-03-22 14:44:04 +0000 | [diff] [blame] | 624 | // We are building the following calls tree: |
| 625 | // -> aaa - sample1 |
| 626 | // aaa -> bbb -> ccc - sample2 |
| 627 | // -> ccc -> aaa - sample3 |
| 628 | TickSample sample1; |
| 629 | sample1.pc = ToAddress(0x1600); |
ulan@chromium.org | 77ca49a | 2013-04-22 09:43:56 +0000 | [diff] [blame] | 630 | sample1.tos = ToAddress(0x1500); |
whesse@chromium.org | cec079d | 2010-03-22 14:44:04 +0000 | [diff] [blame] | 631 | sample1.stack[0] = ToAddress(0x1510); |
| 632 | sample1.frames_count = 1; |
| 633 | generator.RecordTickSample(sample1); |
| 634 | TickSample sample2; |
| 635 | sample2.pc = ToAddress(0x1925); |
ulan@chromium.org | 77ca49a | 2013-04-22 09:43:56 +0000 | [diff] [blame] | 636 | sample2.tos = ToAddress(0x1900); |
whesse@chromium.org | cec079d | 2010-03-22 14:44:04 +0000 | [diff] [blame] | 637 | sample2.stack[0] = ToAddress(0x1780); |
| 638 | sample2.stack[1] = ToAddress(0x10000); // non-existent. |
| 639 | sample2.stack[2] = ToAddress(0x1620); |
| 640 | sample2.frames_count = 3; |
| 641 | generator.RecordTickSample(sample2); |
| 642 | TickSample sample3; |
| 643 | sample3.pc = ToAddress(0x1510); |
ulan@chromium.org | 77ca49a | 2013-04-22 09:43:56 +0000 | [diff] [blame] | 644 | sample3.tos = ToAddress(0x1500); |
whesse@chromium.org | cec079d | 2010-03-22 14:44:04 +0000 | [diff] [blame] | 645 | sample3.stack[0] = ToAddress(0x1910); |
| 646 | sample3.stack[1] = ToAddress(0x1610); |
| 647 | sample3.frames_count = 2; |
| 648 | generator.RecordTickSample(sample3); |
| 649 | |
erik.corry@gmail.com | 9dfbea4 | 2010-05-21 12:58:28 +0000 | [diff] [blame] | 650 | CpuProfile* profile = |
vegorov@chromium.org | 2356e6f | 2010-06-09 09:38:56 +0000 | [diff] [blame] | 651 | profiles.StopProfiling(TokenEnumerator::kNoSecurityToken, "", 1); |
lrn@chromium.org | 25156de | 2010-04-06 13:10:27 +0000 | [diff] [blame] | 652 | CHECK_NE(NULL, profile); |
| 653 | ProfileTreeTestHelper top_down_test_helper(profile->top_down()); |
| 654 | CHECK_EQ(NULL, top_down_test_helper.Walk(entry2)); |
| 655 | CHECK_EQ(NULL, top_down_test_helper.Walk(entry3)); |
whesse@chromium.org | cec079d | 2010-03-22 14:44:04 +0000 | [diff] [blame] | 656 | ProfileNode* node1 = top_down_test_helper.Walk(entry1); |
| 657 | CHECK_NE(NULL, node1); |
| 658 | CHECK_EQ(entry1, node1->entry()); |
| 659 | ProfileNode* node2 = top_down_test_helper.Walk(entry1, entry1); |
| 660 | CHECK_NE(NULL, node2); |
| 661 | CHECK_EQ(entry1, node2->entry()); |
| 662 | ProfileNode* node3 = top_down_test_helper.Walk(entry1, entry2, entry3); |
| 663 | CHECK_NE(NULL, node3); |
| 664 | CHECK_EQ(entry3, node3->entry()); |
| 665 | ProfileNode* node4 = top_down_test_helper.Walk(entry1, entry3, entry1); |
| 666 | CHECK_NE(NULL, node4); |
| 667 | CHECK_EQ(entry1, node4->entry()); |
| 668 | } |
lrn@chromium.org | 25156de | 2010-04-06 13:10:27 +0000 | [diff] [blame] | 669 | |
ricow@chromium.org | c9c8082 | 2010-04-21 08:22:37 +0000 | [diff] [blame] | 670 | |
| 671 | TEST(SampleRateCalculator) { |
| 672 | const double kSamplingIntervalMs = i::Logger::kSamplingIntervalMs; |
| 673 | |
| 674 | // Verify that ticking exactly in query intervals results in the |
| 675 | // initial sampling interval. |
| 676 | double time = 0.0; |
| 677 | SampleRateCalculator calc1; |
| 678 | CHECK_EQ(kSamplingIntervalMs, calc1.ticks_per_ms()); |
| 679 | calc1.UpdateMeasurements(time); |
| 680 | CHECK_EQ(kSamplingIntervalMs, calc1.ticks_per_ms()); |
| 681 | time += SampleRateCalculator::kWallTimeQueryIntervalMs; |
| 682 | calc1.UpdateMeasurements(time); |
| 683 | CHECK_EQ(kSamplingIntervalMs, calc1.ticks_per_ms()); |
| 684 | time += SampleRateCalculator::kWallTimeQueryIntervalMs; |
| 685 | calc1.UpdateMeasurements(time); |
| 686 | CHECK_EQ(kSamplingIntervalMs, calc1.ticks_per_ms()); |
| 687 | time += SampleRateCalculator::kWallTimeQueryIntervalMs; |
| 688 | calc1.UpdateMeasurements(time); |
| 689 | CHECK_EQ(kSamplingIntervalMs, calc1.ticks_per_ms()); |
| 690 | |
| 691 | SampleRateCalculator calc2; |
| 692 | time = 0.0; |
| 693 | CHECK_EQ(kSamplingIntervalMs, calc2.ticks_per_ms()); |
| 694 | calc2.UpdateMeasurements(time); |
| 695 | CHECK_EQ(kSamplingIntervalMs, calc2.ticks_per_ms()); |
| 696 | time += SampleRateCalculator::kWallTimeQueryIntervalMs * 0.5; |
| 697 | calc2.UpdateMeasurements(time); |
| 698 | // (1.0 + 2.0) / 2 |
| 699 | CHECK_EQ(kSamplingIntervalMs * 1.5, calc2.ticks_per_ms()); |
| 700 | time += SampleRateCalculator::kWallTimeQueryIntervalMs * 0.75; |
| 701 | calc2.UpdateMeasurements(time); |
| 702 | // (1.0 + 2.0 + 2.0) / 3 |
fschneider@chromium.org | 40b9da3 | 2010-06-28 11:29:21 +0000 | [diff] [blame] | 703 | CHECK_EQ(kSamplingIntervalMs * 5.0, floor(calc2.ticks_per_ms() * 3.0 + 0.5)); |
ricow@chromium.org | c9c8082 | 2010-04-21 08:22:37 +0000 | [diff] [blame] | 704 | |
| 705 | SampleRateCalculator calc3; |
| 706 | time = 0.0; |
| 707 | CHECK_EQ(kSamplingIntervalMs, calc3.ticks_per_ms()); |
| 708 | calc3.UpdateMeasurements(time); |
| 709 | CHECK_EQ(kSamplingIntervalMs, calc3.ticks_per_ms()); |
| 710 | time += SampleRateCalculator::kWallTimeQueryIntervalMs * 2; |
| 711 | calc3.UpdateMeasurements(time); |
| 712 | // (1.0 + 0.5) / 2 |
| 713 | CHECK_EQ(kSamplingIntervalMs * 0.75, calc3.ticks_per_ms()); |
| 714 | time += SampleRateCalculator::kWallTimeQueryIntervalMs * 1.5; |
| 715 | calc3.UpdateMeasurements(time); |
| 716 | // (1.0 + 0.5 + 0.5) / 3 |
fschneider@chromium.org | 40b9da3 | 2010-06-28 11:29:21 +0000 | [diff] [blame] | 717 | CHECK_EQ(kSamplingIntervalMs * 2.0, floor(calc3.ticks_per_ms() * 3.0 + 0.5)); |
ricow@chromium.org | c9c8082 | 2010-04-21 08:22:37 +0000 | [diff] [blame] | 718 | } |
| 719 | |
sgjesse@chromium.org | 82dbbab | 2010-06-02 08:57:44 +0000 | [diff] [blame] | 720 | |
mstarzinger@chromium.org | f705b50 | 2013-04-04 11:38:09 +0000 | [diff] [blame] | 721 | static void CheckNodeIds(ProfileNode* node, int* expectedId) { |
| 722 | CHECK_EQ((*expectedId)++, node->id()); |
| 723 | for (int i = 0; i < node->children()->length(); i++) { |
| 724 | CheckNodeIds(node->children()->at(i), expectedId); |
| 725 | } |
| 726 | } |
| 727 | |
| 728 | TEST(SampleIds) { |
| 729 | TestSetup test_setup; |
| 730 | CpuProfilesCollection profiles; |
| 731 | profiles.StartProfiling("", 1, true); |
| 732 | ProfileGenerator generator(&profiles); |
danno@chromium.org | ca29dd8 | 2013-04-26 11:59:48 +0000 | [diff] [blame] | 733 | CodeEntry* entry1 = profiles.NewCodeEntry(i::Logger::FUNCTION_TAG, "aaa"); |
| 734 | CodeEntry* entry2 = profiles.NewCodeEntry(i::Logger::FUNCTION_TAG, "bbb"); |
| 735 | CodeEntry* entry3 = profiles.NewCodeEntry(i::Logger::FUNCTION_TAG, "ccc"); |
mstarzinger@chromium.org | f705b50 | 2013-04-04 11:38:09 +0000 | [diff] [blame] | 736 | generator.code_map()->AddCode(ToAddress(0x1500), entry1, 0x200); |
| 737 | generator.code_map()->AddCode(ToAddress(0x1700), entry2, 0x100); |
| 738 | generator.code_map()->AddCode(ToAddress(0x1900), entry3, 0x50); |
| 739 | |
| 740 | // We are building the following calls tree: |
| 741 | // -> aaa #3 - sample1 |
| 742 | // (root)#1 -> aaa #2 -> bbb #4 -> ccc #5 - sample2 |
| 743 | // -> ccc #6 -> aaa #7 - sample3 |
| 744 | TickSample sample1; |
| 745 | sample1.pc = ToAddress(0x1600); |
| 746 | sample1.stack[0] = ToAddress(0x1510); |
| 747 | sample1.frames_count = 1; |
| 748 | generator.RecordTickSample(sample1); |
| 749 | TickSample sample2; |
| 750 | sample2.pc = ToAddress(0x1925); |
| 751 | sample2.stack[0] = ToAddress(0x1780); |
| 752 | sample2.stack[1] = ToAddress(0x10000); // non-existent. |
| 753 | sample2.stack[2] = ToAddress(0x1620); |
| 754 | sample2.frames_count = 3; |
| 755 | generator.RecordTickSample(sample2); |
| 756 | TickSample sample3; |
| 757 | sample3.pc = ToAddress(0x1510); |
| 758 | sample3.stack[0] = ToAddress(0x1910); |
| 759 | sample3.stack[1] = ToAddress(0x1610); |
| 760 | sample3.frames_count = 2; |
| 761 | generator.RecordTickSample(sample3); |
| 762 | |
| 763 | CpuProfile* profile = |
| 764 | profiles.StopProfiling(TokenEnumerator::kNoSecurityToken, "", 1); |
| 765 | int nodeId = 1; |
| 766 | CheckNodeIds(profile->top_down()->root(), &nodeId); |
| 767 | CHECK_EQ(7, nodeId - 1); |
| 768 | |
| 769 | CHECK_EQ(3, profile->samples_count()); |
| 770 | int expected_id[] = {3, 5, 7}; |
| 771 | for (int i = 0; i < 3; i++) { |
| 772 | CHECK_EQ(expected_id[i], profile->sample(i)->id()); |
| 773 | } |
| 774 | } |
| 775 | |
| 776 | |
| 777 | TEST(NoSamples) { |
| 778 | TestSetup test_setup; |
| 779 | CpuProfilesCollection profiles; |
| 780 | profiles.StartProfiling("", 1, false); |
| 781 | ProfileGenerator generator(&profiles); |
danno@chromium.org | ca29dd8 | 2013-04-26 11:59:48 +0000 | [diff] [blame] | 782 | CodeEntry* entry1 = profiles.NewCodeEntry(i::Logger::FUNCTION_TAG, "aaa"); |
mstarzinger@chromium.org | f705b50 | 2013-04-04 11:38:09 +0000 | [diff] [blame] | 783 | generator.code_map()->AddCode(ToAddress(0x1500), entry1, 0x200); |
| 784 | |
| 785 | // We are building the following calls tree: |
| 786 | // (root)#1 -> aaa #2 -> aaa #3 - sample1 |
| 787 | TickSample sample1; |
| 788 | sample1.pc = ToAddress(0x1600); |
| 789 | sample1.stack[0] = ToAddress(0x1510); |
| 790 | sample1.frames_count = 1; |
| 791 | generator.RecordTickSample(sample1); |
| 792 | |
| 793 | CpuProfile* profile = |
| 794 | profiles.StopProfiling(TokenEnumerator::kNoSecurityToken, "", 1); |
| 795 | int nodeId = 1; |
| 796 | CheckNodeIds(profile->top_down()->root(), &nodeId); |
| 797 | CHECK_EQ(3, nodeId - 1); |
| 798 | |
| 799 | CHECK_EQ(0, profile->samples_count()); |
| 800 | } |
| 801 | |
| 802 | |
sgjesse@chromium.org | 82dbbab | 2010-06-02 08:57:44 +0000 | [diff] [blame] | 803 | // --- P r o f i l e r E x t e n s i o n --- |
| 804 | |
| 805 | class ProfilerExtension : public v8::Extension { |
| 806 | public: |
| 807 | ProfilerExtension() : v8::Extension("v8/profiler", kSource) { } |
| 808 | virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction( |
| 809 | v8::Handle<v8::String> name); |
| 810 | static v8::Handle<v8::Value> StartProfiling(const v8::Arguments& args); |
| 811 | static v8::Handle<v8::Value> StopProfiling(const v8::Arguments& args); |
| 812 | private: |
| 813 | static const char* kSource; |
| 814 | }; |
| 815 | |
| 816 | |
| 817 | const char* ProfilerExtension::kSource = |
| 818 | "native function startProfiling();" |
| 819 | "native function stopProfiling();"; |
| 820 | |
| 821 | v8::Handle<v8::FunctionTemplate> ProfilerExtension::GetNativeFunction( |
| 822 | v8::Handle<v8::String> name) { |
| 823 | if (name->Equals(v8::String::New("startProfiling"))) { |
| 824 | return v8::FunctionTemplate::New(ProfilerExtension::StartProfiling); |
| 825 | } else if (name->Equals(v8::String::New("stopProfiling"))) { |
| 826 | return v8::FunctionTemplate::New(ProfilerExtension::StopProfiling); |
| 827 | } else { |
| 828 | CHECK(false); |
| 829 | return v8::Handle<v8::FunctionTemplate>(); |
| 830 | } |
| 831 | } |
| 832 | |
| 833 | |
| 834 | v8::Handle<v8::Value> ProfilerExtension::StartProfiling( |
| 835 | const v8::Arguments& args) { |
mstarzinger@chromium.org | f705b50 | 2013-04-04 11:38:09 +0000 | [diff] [blame] | 836 | v8::CpuProfiler* cpu_profiler = args.GetIsolate()->GetCpuProfiler(); |
sgjesse@chromium.org | 82dbbab | 2010-06-02 08:57:44 +0000 | [diff] [blame] | 837 | if (args.Length() > 0) |
mstarzinger@chromium.org | f705b50 | 2013-04-04 11:38:09 +0000 | [diff] [blame] | 838 | cpu_profiler->StartCpuProfiling(args[0].As<v8::String>()); |
sgjesse@chromium.org | 82dbbab | 2010-06-02 08:57:44 +0000 | [diff] [blame] | 839 | else |
mstarzinger@chromium.org | f705b50 | 2013-04-04 11:38:09 +0000 | [diff] [blame] | 840 | cpu_profiler->StartCpuProfiling(v8::String::New("")); |
sgjesse@chromium.org | 82dbbab | 2010-06-02 08:57:44 +0000 | [diff] [blame] | 841 | return v8::Undefined(); |
| 842 | } |
| 843 | |
| 844 | |
| 845 | v8::Handle<v8::Value> ProfilerExtension::StopProfiling( |
| 846 | const v8::Arguments& args) { |
mstarzinger@chromium.org | f705b50 | 2013-04-04 11:38:09 +0000 | [diff] [blame] | 847 | v8::CpuProfiler* cpu_profiler = args.GetIsolate()->GetCpuProfiler(); |
sgjesse@chromium.org | 82dbbab | 2010-06-02 08:57:44 +0000 | [diff] [blame] | 848 | if (args.Length() > 0) |
mstarzinger@chromium.org | f705b50 | 2013-04-04 11:38:09 +0000 | [diff] [blame] | 849 | cpu_profiler->StopCpuProfiling(args[0].As<v8::String>()); |
sgjesse@chromium.org | 82dbbab | 2010-06-02 08:57:44 +0000 | [diff] [blame] | 850 | else |
mstarzinger@chromium.org | f705b50 | 2013-04-04 11:38:09 +0000 | [diff] [blame] | 851 | cpu_profiler->StopCpuProfiling(v8::String::New("")); |
sgjesse@chromium.org | 82dbbab | 2010-06-02 08:57:44 +0000 | [diff] [blame] | 852 | return v8::Undefined(); |
| 853 | } |
| 854 | |
| 855 | |
| 856 | static ProfilerExtension kProfilerExtension; |
| 857 | v8::DeclareExtension kProfilerExtensionDeclaration(&kProfilerExtension); |
sgjesse@chromium.org | 82dbbab | 2010-06-02 08:57:44 +0000 | [diff] [blame] | 858 | |
| 859 | static const ProfileNode* PickChild(const ProfileNode* parent, |
| 860 | const char* name) { |
| 861 | for (int i = 0; i < parent->children()->length(); ++i) { |
| 862 | const ProfileNode* child = parent->children()->at(i); |
| 863 | if (strcmp(child->entry()->name(), name) == 0) return child; |
| 864 | } |
| 865 | return NULL; |
| 866 | } |
| 867 | |
| 868 | |
| 869 | TEST(RecordStackTraceAtStartProfiling) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 870 | // This test does not pass with inlining enabled since inlined functions |
| 871 | // don't appear in the stack trace. |
| 872 | i::FLAG_use_inlining = false; |
| 873 | |
ulan@chromium.org | 57ff881 | 2013-05-10 08:16:55 +0000 | [diff] [blame^] | 874 | v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
| 875 | v8::HandleScope scope(isolate); |
| 876 | const char* extensions[] = { "v8/profiler" }; |
| 877 | v8::ExtensionConfiguration config(1, extensions); |
| 878 | v8::Local<v8::Context> context = v8::Context::New(isolate); |
| 879 | context->Enter(); |
sgjesse@chromium.org | 82dbbab | 2010-06-02 08:57:44 +0000 | [diff] [blame] | 880 | |
mstarzinger@chromium.org | f705b50 | 2013-04-04 11:38:09 +0000 | [diff] [blame] | 881 | CpuProfiler* profiler = i::Isolate::Current()->cpu_profiler(); |
| 882 | CHECK_EQ(0, profiler->GetProfilesCount()); |
sgjesse@chromium.org | 82dbbab | 2010-06-02 08:57:44 +0000 | [diff] [blame] | 883 | CompileRun( |
| 884 | "function c() { startProfiling(); }\n" |
| 885 | "function b() { c(); }\n" |
| 886 | "function a() { b(); }\n" |
| 887 | "a();\n" |
| 888 | "stopProfiling();"); |
mstarzinger@chromium.org | f705b50 | 2013-04-04 11:38:09 +0000 | [diff] [blame] | 889 | CHECK_EQ(1, profiler->GetProfilesCount()); |
| 890 | CpuProfile* profile = profiler->GetProfile(NULL, 0); |
sgjesse@chromium.org | 82dbbab | 2010-06-02 08:57:44 +0000 | [diff] [blame] | 891 | const ProfileTree* topDown = profile->top_down(); |
| 892 | const ProfileNode* current = topDown->root(); |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 893 | const_cast<ProfileNode*>(current)->Print(0); |
sgjesse@chromium.org | 82dbbab | 2010-06-02 08:57:44 +0000 | [diff] [blame] | 894 | // The tree should look like this: |
| 895 | // (root) |
| 896 | // (anonymous function) |
| 897 | // a |
| 898 | // b |
| 899 | // c |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 900 | // There can also be: |
| 901 | // startProfiling |
| 902 | // if the sampler managed to get a tick. |
sgjesse@chromium.org | 82dbbab | 2010-06-02 08:57:44 +0000 | [diff] [blame] | 903 | current = PickChild(current, "(anonymous function)"); |
| 904 | CHECK_NE(NULL, const_cast<ProfileNode*>(current)); |
| 905 | current = PickChild(current, "a"); |
| 906 | CHECK_NE(NULL, const_cast<ProfileNode*>(current)); |
| 907 | current = PickChild(current, "b"); |
| 908 | CHECK_NE(NULL, const_cast<ProfileNode*>(current)); |
| 909 | current = PickChild(current, "c"); |
| 910 | CHECK_NE(NULL, const_cast<ProfileNode*>(current)); |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 911 | CHECK(current->children()->length() == 0 || |
| 912 | current->children()->length() == 1); |
| 913 | if (current->children()->length() == 1) { |
| 914 | current = PickChild(current, "startProfiling"); |
| 915 | CHECK_EQ(0, current->children()->length()); |
| 916 | } |
sgjesse@chromium.org | 82dbbab | 2010-06-02 08:57:44 +0000 | [diff] [blame] | 917 | } |
| 918 | |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 919 | |
| 920 | TEST(Issue51919) { |
| 921 | CpuProfilesCollection collection; |
| 922 | i::EmbeddedVector<char*, |
| 923 | CpuProfilesCollection::kMaxSimultaneousProfiles> titles; |
| 924 | for (int i = 0; i < CpuProfilesCollection::kMaxSimultaneousProfiles; ++i) { |
| 925 | i::Vector<char> title = i::Vector<char>::New(16); |
| 926 | i::OS::SNPrintF(title, "%d", i); |
mstarzinger@chromium.org | f705b50 | 2013-04-04 11:38:09 +0000 | [diff] [blame] | 927 | // UID must be > 0. |
| 928 | CHECK(collection.StartProfiling(title.start(), i + 1, false)); |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 929 | titles[i] = title.start(); |
| 930 | } |
| 931 | CHECK(!collection.StartProfiling( |
mstarzinger@chromium.org | f705b50 | 2013-04-04 11:38:09 +0000 | [diff] [blame] | 932 | "maximum", CpuProfilesCollection::kMaxSimultaneousProfiles + 1, false)); |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 933 | for (int i = 0; i < CpuProfilesCollection::kMaxSimultaneousProfiles; ++i) |
| 934 | i::DeleteArray(titles[i]); |
| 935 | } |