Ignore:
Timestamp:
Apr 18, 2008, 2:49:56 PM (17 years ago)
Author:
[email protected]
Message:

2008-04-18 Kevin McCullough <[email protected]>

Reviewed by Sam and Adam.

-<rdar://problem/5770054> JavaScript profiler (10928)

  • Cleaned up the header file and made some functions static, added a new, sane, printing function, and fixed a few minor bugs.
  • JavaScriptCore.exp:
  • JavaScriptCore.xcodeproj/project.pbxproj:
  • profiler/FunctionCallProfile.cpp: (KJS::FunctionCallProfile::didExecute): Removed assertion that time is

    0 because at ms resolution that may not be true and only cross-

    platform way to get time differences is in ms. (KJS::FunctionCallProfile::printDataInspectorStyle): Added a new printing function for dumping data in a sane style. (KJS::FunctionCallProfile::printDataSampleStyle): Fixed a bug where we displayed too much precision when printing our floats. Also added logic to make sure we don't display 0 because that doesn't make sense for a sampling profile.
  • profiler/FunctionCallProfile.h:
  • profiler/Profiler.cpp: Moved functions that could be static into the implementation, and chaned the ASSERTs to early returns. I did this because console.profile() is a JS function and so was being profiled but asserting because the profiler had not been started! In the future I would like to put the ASSERTs back and not profile the calls to console.profile() and console.profileEnd(). (KJS::Profiler::willExecute): (KJS::Profiler::didExecute): (KJS::getStackNames): Fixed a bug where the wrong ExecState was being used. (KJS::getFunctionName): (KJS::Profiler::printDataInspectorStyle):
  • profiler/Profiler.h:
File:
1 edited

Legend:

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

    r32198 r32228  
    6262        m_timeSum += getCurrentUTCTime() - m_startTime;
    6363
    64         ASSERT(m_timeSum > 0);
     64        // FIXME: We may need something with higher resolution than ms as some functions will take 0ms.
    6565        return;
    6666    }
     
    9797}
    9898
     99void FunctionCallProfile::printDataInspectorStyle(int indentLevel) const
     100{
     101    // Print function names
     102    if (indentLevel) {
     103        for (int i = 0; i < indentLevel; ++i)
     104            printf("  ");
     105
     106        printf("%.0fms %s\n", m_timeSum, m_functionName.UTF8String().c_str());
     107    } else
     108        printf("%s\n", m_functionName.UTF8String().c_str());
     109
     110    ++indentLevel;
     111
     112    // Print children's names and information
     113    for (StackIterator currentChild = m_children.begin(); currentChild != m_children.end(); ++currentChild)
     114        (*currentChild)->printDataInspectorStyle(indentLevel);
     115}
     116
    99117// print the profiled data in a format that matches the tool sample's output.
    100 double FunctionCallProfile::printDataSampleStyle(int indentLevel)
     118double FunctionCallProfile::printDataSampleStyle(int indentLevel) const
    101119{
    102120    printf("    ");
     
    108126
    109127        // We've previously asserted that m_timeSum will always be >= 1
    110         printf("%f %s\n", m_timeSum, m_functionName.UTF8String().c_str());
     128        printf("%.0f %s\n", m_timeSum ? m_timeSum : 1, m_functionName.UTF8String().c_str());
    111129    } else
    112130        printf("%s\n", m_functionName.UTF8String().c_str());
Note: See TracChangeset for help on using the changeset viewer.