Ignore:
Timestamp:
May 19, 2008, 3:15:30 PM (17 years ago)
Author:
[email protected]
Message:

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

Reviewed by Tim.

<rdar://problem/5770054> JavaScript profiler (10928)
-In an effort to make the profiler as efficient as possible instead of
prepending to a vector we keep the vector in reverse order and operate
over it backwards.

  • profiler/Profile.cpp: (KJS::Profile::willExecute): (KJS::Profile::didExecute):
  • profiler/ProfileNode.cpp: (KJS::ProfileNode::didExecute): (KJS::ProfileNode::endAndRecordCall):
  • profiler/ProfileNode.h:
  • profiler/Profiler.cpp: (KJS::getStackNames):
File:
1 edited

Legend:

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

    r33532 r33581  
    5353}
    5454
    55 void ProfileNode::didExecute(Vector<UString> stackNames, unsigned int stackIndex)
    56 {
    57     if (stackIndex && stackIndex == stackNames.size()) {
    58         ASSERT(stackNames[stackIndex - 1] == m_functionName);
    59         endAndRecordCall();
    60         return;
    61     }
    62 
    63     for (StackIterator currentChild = m_children.begin(); currentChild != m_children.end() && stackIndex < stackNames.size(); ++currentChild) {
    64         if ((*currentChild)->functionName() == stackNames[stackIndex]) {
    65             (*currentChild)->didExecute(stackNames, ++stackIndex);
     55// We start at the end of stackNames and work our way forwards since the names are in
     56// the reverse order of how the ProfileNode tree is created (e.g. the leaf node is at
     57// index 0 and the top of the stack is at index stackNames.size() - 1)
     58void ProfileNode::didExecute(const Vector<UString>& stackNames, unsigned int stackIndex)
     59{
     60    for (size_t i = 0; i < m_children.size(); ++i) {
     61        if (m_children[i]->functionName() == stackNames[stackIndex]) {
     62            if (stackIndex)   // We are not at the bottom of the stack yet
     63                m_children[i]->didExecute(stackNames, stackIndex - 1);
     64            else    // This is the child we were looking for
     65                m_children[i]->endAndRecordCall();
    6666            return;
    6767        }
     
    189189    for (StackIterator currentChild = m_children.begin(); currentChild != m_children.end(); ++currentChild)
    190190        (*currentChild)->sortCallsAscending();
     191}
     192
     193void ProfileNode::endAndRecordCall()
     194{
     195    m_totalTime += getCurrentUTCTime() - m_startTime;
     196    m_startTime = 0.0;
     197
     198    ++m_numberOfCalls;
    191199}
    192200
     
    247255}
    248256
    249 void ProfileNode::endAndRecordCall()
    250 {
    251     m_totalTime += getCurrentUTCTime() - m_startTime;
    252     m_startTime = 0.0;
    253 
    254     ++m_numberOfCalls;
    255 }
    256 
    257257}   // namespace KJS
Note: See TracChangeset for help on using the changeset viewer.