Ignore:
Timestamp:
May 16, 2008, 3:23:09 PM (17 years ago)
Author:
[email protected]
Message:

JavaScriptCore:

2008-05-16 Kevin McCullough <[email protected]>

Reviewed by Tim.

<rdar://problem/5770054> JavaScript profiler (10928)
Implement sorting for the profiler.
I chose to sort the profileNodes in place since there is no reason they
need to retain their original order.

  • JavaScriptCore.exp: Export the symbols.
  • profiler/Profile.h: Add the different ways a profile can be sorted. (KJS::Profile::sortTotalTimeDescending): (KJS::Profile::sortTotalTimeAscending): (KJS::Profile::sortSelfTimeDescending): (KJS::Profile::sortSelfTimeAscending): (KJS::Profile::sortCallsDescending): (KJS::Profile::sortCallsAscending):
  • profiler/ProfileNode.cpp: Implement those ways. (KJS::totalTimeDescendingComparator): (KJS::ProfileNode::sortTotalTimeDescending): (KJS::totalTimeAscendingComparator): (KJS::ProfileNode::sortTotalTimeAscending): (KJS::selfTimeDescendingComparator): (KJS::ProfileNode::sortSelfTimeDescending): (KJS::selfTimeAscendingComparator): (KJS::ProfileNode::sortSelfTimeAscending): (KJS::callsDescendingComparator): (KJS::ProfileNode::sortCallsDescending): (KJS::callsAscendingComparator): (KJS::ProfileNode::sortCallsAscending):
  • profiler/ProfileNode.h: No longer use a Deque since it cannot be sorted by std::sort and there was no reason not to use a Vector. I previously had though I would do prepending but am not. (KJS::ProfileNode::selfTime): (KJS::ProfileNode::totalPercent): (KJS::ProfileNode::selfPercent): (KJS::ProfileNode::children):
  • profiler/Profiler.cpp: Removed these functions as they can be called directoy on the Profile object after getting the Vector of them. (KJS::getStackNames):
  • profiler/Profiler.h:

WebCore:

2008-05-16 Kevin McCullough <[email protected]>

Reviewed by Tim.

<rdar://problem/5770054> JavaScript profiler (10928)
Use a Vector instead of a Deque since we don't use the extra capabilities
of the Deque.

  • page/JavaScriptProfileNode.cpp: (WebCore::getChildren): (WebCore::toJS):
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/profiler/ProfileNode.cpp

    r33507 r33532  
    111111}
    112112
     113#pragma mark Sorting methods
     114
     115static inline bool totalTimeDescendingComparator(const RefPtr<ProfileNode>& a, const RefPtr<ProfileNode>& b)
     116{
     117    return a->totalTime() > b->totalTime();
     118}
     119
     120void ProfileNode::sortTotalTimeDescending()
     121{
     122    std::sort(m_children.begin(), m_children.end(), totalTimeDescendingComparator);
     123
     124    for (StackIterator currentChild = m_children.begin(); currentChild != m_children.end(); ++currentChild)
     125        (*currentChild)->sortTotalTimeDescending();
     126}
     127
     128static inline bool totalTimeAscendingComparator(const RefPtr<ProfileNode>& a, const RefPtr<ProfileNode>& b)
     129{
     130    return a->totalTime() < b->totalTime();
     131}
     132
     133void ProfileNode::sortTotalTimeAscending()
     134{
     135    std::sort(m_children.begin(), m_children.end(), totalTimeAscendingComparator);
     136
     137    for (StackIterator currentChild = m_children.begin(); currentChild != m_children.end(); ++currentChild)
     138        (*currentChild)->sortTotalTimeAscending();
     139}
     140
     141static inline bool selfTimeDescendingComparator(const RefPtr<ProfileNode>& a, const RefPtr<ProfileNode>& b)
     142{
     143    return a->selfTime() > b->selfTime();
     144}
     145
     146void ProfileNode::sortSelfTimeDescending()
     147{
     148    std::sort(m_children.begin(), m_children.end(), selfTimeDescendingComparator);
     149
     150    for (StackIterator currentChild = m_children.begin(); currentChild != m_children.end(); ++currentChild)
     151        (*currentChild)->sortSelfTimeDescending();
     152}
     153
     154static inline bool selfTimeAscendingComparator(const RefPtr<ProfileNode>& a, const RefPtr<ProfileNode>& b)
     155{
     156    return a->selfTime() < b->selfTime();
     157}
     158
     159void ProfileNode::sortSelfTimeAscending()
     160{
     161    std::sort(m_children.begin(), m_children.end(), selfTimeAscendingComparator);
     162
     163    for (StackIterator currentChild = m_children.begin(); currentChild != m_children.end(); ++currentChild)
     164        (*currentChild)->sortSelfTimeAscending();
     165}
     166
     167static inline bool callsDescendingComparator(const RefPtr<ProfileNode>& a, const RefPtr<ProfileNode>& b)
     168{
     169    return a->numberOfCalls() > b->numberOfCalls();
     170}
     171
     172void ProfileNode::sortCallsDescending()
     173{
     174    std::sort(m_children.begin(), m_children.end(), callsDescendingComparator);
     175
     176    for (StackIterator currentChild = m_children.begin(); currentChild != m_children.end(); ++currentChild)
     177        (*currentChild)->sortCallsDescending();
     178}
     179
     180static inline bool callsAscendingComparator(const RefPtr<ProfileNode>& a, const RefPtr<ProfileNode>& b)
     181{
     182    return a->numberOfCalls() < b->numberOfCalls();
     183}
     184
     185void ProfileNode::sortCallsAscending()
     186{
     187    std::sort(m_children.begin(), m_children.end(), callsAscendingComparator);
     188
     189    for (StackIterator currentChild = m_children.begin(); currentChild != m_children.end(); ++currentChild)
     190        (*currentChild)->sortCallsAscending();
     191}
     192
    113193void ProfileNode::printDataInspectorStyle(int indentLevel) const
    114194{
Note: See TracChangeset for help on using the changeset viewer.