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/Profile.cpp

    r33466 r33581  
    3636namespace KJS {
    3737
    38 typedef Vector<UString>::const_iterator NameIterator;
    39 
    4038Profile::Profile(const UString& title)
    4139    : m_title(title)
     
    4644}
    4745
     46// The callStackNames are in order of bottom of the stack to top of the stack so we iterate it backwards.
    4847void Profile::willExecute(const Vector<UString>& callStackNames)
    4948{
    5049    RefPtr<ProfileNode> callTreeInsertionPoint;
    5150    RefPtr<ProfileNode> foundNameInTree = m_callTree;
    52     NameIterator callStackLocation = callStackNames.begin();
    5351
    54     while (callStackLocation != callStackNames.end() && foundNameInTree) {
     52    int i = callStackNames.size();
     53    while (foundNameInTree && i) {
    5554        callTreeInsertionPoint = foundNameInTree;
    56         foundNameInTree = callTreeInsertionPoint->findChild(*callStackLocation);
    57         ++callStackLocation;
     55        foundNameInTree = callTreeInsertionPoint->findChild(callStackNames[--i]);
    5856    }
    5957
    6058    if (!foundNameInTree) {   // Insert remains of the stack into the call tree.
    61         --callStackLocation;
    62         for (RefPtr<ProfileNode> next; callStackLocation != callStackNames.end(); ++callStackLocation) {
    63             next = ProfileNode::create(*callStackLocation);
     59        for (RefPtr<ProfileNode> next; i >= 0; callTreeInsertionPoint = next) {
     60            next = ProfileNode::create(callStackNames[i--]);
    6461            callTreeInsertionPoint->addChild(next);
    65             callTreeInsertionPoint = next;
    6662        }
    6763    } else    // We are calling a function that is already in the call tree.
     
    7167void Profile::didExecute(const Vector<UString>& stackNames)
    7268{
    73     m_callTree->didExecute(stackNames, 0);   
     69    ASSERT(stackNames.size());
     70    if (!stackNames.size())
     71        return;
     72
     73    m_callTree->didExecute(stackNames, stackNames.size() - 1);
    7474}
    7575
Note: See TracChangeset for help on using the changeset viewer.