Changeset 34362 in webkit for trunk/JavaScriptCore/profiler/ProfileNode.cpp
- Timestamp:
- Jun 4, 2008, 11:53:10 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/profiler/ProfileNode.cpp
r34310 r34362 70 70 , m_visible(true) 71 71 { 72 if (!m_head)73 m_head = this;74 75 72 startTimer(); 76 73 } … … 85 82 } 86 83 87 RefPtr<ProfileNode> newChild = ProfileNode::create(callIdentifier, m_head , this);84 RefPtr<ProfileNode> newChild = ProfileNode::create(callIdentifier, m_head ? m_head : this, this); // If this ProfileNode has no head it is the head. 88 85 if (m_children.size()) 89 86 m_children.last()->setNextSibling(newChild.get()); … … 137 134 m_actualSelfTime = m_actualTotalTime - m_actualSelfTime; 138 135 139 if ( m_head == this&& m_actualSelfTime) {136 if (!m_head && m_actualSelfTime) { 140 137 ProfileNode* idleNode = willExecute(CallIdentifier(NonJSExecution, 0, 0)); 141 138 … … 150 147 } 151 148 152 // Sorting methods 153 154 static inline bool totalTimeDescendingComparator(const RefPtr<ProfileNode>& a, const RefPtr<ProfileNode>& b) 155 { 156 return a->totalTime() > b->totalTime(); 157 } 158 159 void ProfileNode::sortTotalTimeDescending() 160 { 161 std::sort(m_children.begin(), m_children.end(), totalTimeDescendingComparator); 162 163 unsigned size = m_children.size(); 164 for (unsigned i = 0; i < size; ++i) 165 m_children[i]->sortTotalTimeDescending(); 166 167 resetChildrensSiblings(); 168 } 169 170 static inline bool totalTimeAscendingComparator(const RefPtr<ProfileNode>& a, const RefPtr<ProfileNode>& b) 171 { 172 return a->totalTime() < b->totalTime(); 173 } 174 175 void ProfileNode::sortTotalTimeAscending() 176 { 177 std::sort(m_children.begin(), m_children.end(), totalTimeAscendingComparator); 178 179 unsigned size = m_children.size(); 180 for (unsigned i = 0; i < size; ++i) 181 m_children[i]->sortTotalTimeAscending(); 182 183 resetChildrensSiblings(); 184 } 185 186 static inline bool selfTimeDescendingComparator(const RefPtr<ProfileNode>& a, const RefPtr<ProfileNode>& b) 187 { 188 return a->selfTime() > b->selfTime(); 189 } 190 191 void ProfileNode::sortSelfTimeDescending() 192 { 193 std::sort(m_children.begin(), m_children.end(), selfTimeDescendingComparator); 194 195 unsigned size = m_children.size(); 196 for (unsigned i = 0; i < size; ++i) 197 m_children[i]->sortSelfTimeDescending(); 198 199 resetChildrensSiblings(); 200 } 201 202 static inline bool selfTimeAscendingComparator(const RefPtr<ProfileNode>& a, const RefPtr<ProfileNode>& b) 203 { 204 return a->selfTime() < b->selfTime(); 205 } 206 207 void ProfileNode::sortSelfTimeAscending() 208 { 209 std::sort(m_children.begin(), m_children.end(), selfTimeAscendingComparator); 210 211 unsigned size = m_children.size(); 212 for (unsigned i = 0; i < size; ++i) 213 m_children[i]->sortSelfTimeAscending(); 214 215 resetChildrensSiblings(); 216 } 217 218 static inline bool callsDescendingComparator(const RefPtr<ProfileNode>& a, const RefPtr<ProfileNode>& b) 219 { 220 return a->numberOfCalls() > b->numberOfCalls(); 221 } 222 223 void ProfileNode::sortCallsDescending() 224 { 225 std::sort(m_children.begin(), m_children.end(), callsDescendingComparator); 226 227 unsigned size = m_children.size(); 228 for (unsigned i = 0; i < size; ++i) 229 m_children[i]->sortCallsDescending(); 230 231 resetChildrensSiblings(); 232 } 233 234 static inline bool callsAscendingComparator(const RefPtr<ProfileNode>& a, const RefPtr<ProfileNode>& b) 235 { 236 return a->numberOfCalls() < b->numberOfCalls(); 237 } 238 239 void ProfileNode::sortCallsAscending() 240 { 241 std::sort(m_children.begin(), m_children.end(), callsAscendingComparator); 242 243 unsigned size = m_children.size(); 244 for (unsigned i = 0; i < size; ++i) 245 m_children[i]->sortCallsAscending(); 246 247 resetChildrensSiblings(); 248 } 249 250 static inline bool functionNameDescendingComparator(const RefPtr<ProfileNode>& a, const RefPtr<ProfileNode>& b) 251 { 252 return a->functionName() > b->functionName(); 253 } 254 255 void ProfileNode::sortFunctionNameDescending() 256 { 257 std::sort(m_children.begin(), m_children.end(), functionNameDescendingComparator); 258 259 unsigned size = m_children.size(); 260 for (unsigned i = 0; i < size; ++i) 261 m_children[i]->sortFunctionNameDescending(); 262 263 resetChildrensSiblings(); 264 } 265 266 static inline bool functionNameAscendingComparator(const RefPtr<ProfileNode>& a, const RefPtr<ProfileNode>& b) 267 { 268 return a->functionName() < b->functionName(); 269 } 270 271 void ProfileNode::sortFunctionNameAscending() 272 { 273 std::sort(m_children.begin(), m_children.end(), functionNameAscendingComparator); 274 275 unsigned size = m_children.size(); 276 for (unsigned i = 0; i < size; ++i) 277 m_children[i]->sortFunctionNameAscending(); 278 149 ProfileNode* ProfileNode::traverseNextNode() const 150 { 151 ProfileNode* next = m_nextSibling; 152 if (!next) 153 return m_parent; 154 while (ProfileNode* firstChild = next->firstChild()) 155 next = firstChild; 156 return next; 157 } 158 159 void ProfileNode::sort(bool comparator(const RefPtr<ProfileNode>& , const RefPtr<ProfileNode>& )) 160 { 161 std::sort(childrenBegin(), childrenEnd(), comparator); 279 162 resetChildrensSiblings(); 280 163 }
Note:
See TracChangeset
for help on using the changeset viewer.