Ignore:
Timestamp:
May 1, 2008, 9:32:32 AM (17 years ago)
Author:
[email protected]
Message:

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

Reviewed by Darin.

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

  • Fix "sample" output so that it can be imported into Instruments
  • Also keep track of number of times a function is profiled.
  • JavaScriptCore.xcodeproj/project.pbxproj: Add StrHash.h which needed to be pulled out of identifier.cpp so that it could be used by the profiler and identifiers.
  • kjs/identifier.cpp: Ditto.
  • profiler/FunctionCallProfile.cpp: (KJS::FunctionCallProfile::printDataInspectorStyle): Inspector style printing should show microseconds. (KJS::FunctionCallProfile::printDataSampleStyle): Sample style printing now counts the number of times a function is in the stack tree and does not print microseconds since that does not make sense for a sampler.
  • profiler/FunctionCallProfile.h: Keep track of number of times a function is profiled. (KJS::FunctionCallProfile::numberOfCalls):
  • profiler/Profiler.cpp: (KJS::functionNameCountPairComparator): Comparator for sort function in printDataSampleStyle. (KJS::Profiler::printDataSampleStyle): Print the number of times that a function is listed in the stack tree in order of most times listed.
  • wtf/HashCountedSet.h: Added copyToVector since it didn't exist and is a more standard way to copy a HashSet to a Vector. I added on variant that takes a pair as the Vector's type and so the HashCountedSet simply fills in that pair with its internal pair, and another variant that takes a Vector of the type of the HashCountedSet and only fills in the Vector with the first element of the pair. (WTF::copyToVector):
  • wtf/StrHash.h: Added. (WTF::):
File:
1 edited

Legend:

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

    r32693 r32760  
    112112            printf("  ");
    113113
    114         printf("%.0fms %s\n", m_timeSum, m_functionName.UTF8String().c_str());
     114        printf("%.3fms %s\n", m_timeSum, m_functionName.UTF8String().c_str());
    115115    } else
    116116        printf("%s\n", m_functionName.UTF8String().c_str());
     
    124124
    125125// print the profiled data in a format that matches the tool sample's output.
    126 double FunctionCallProfile::printDataSampleStyle(int indentLevel) const
     126double FunctionCallProfile::printDataSampleStyle(int indentLevel, FunctionCallHashCount& countedFunctions) const
    127127{
    128128    printf("    ");
    129129
    130130    // Print function names
     131    const char* name = m_functionName.UTF8String().c_str();
     132    double sampleCount = m_timeSum * 1000;
    131133    if (indentLevel) {
    132134        for (int i = 0; i < indentLevel; ++i)
    133135            printf("  ");
    134136
    135         // We've previously asserted that m_timeSum will always be >= 1
    136         printf("%.0f %s\n", m_timeSum ? m_timeSum : 1, m_functionName.UTF8String().c_str());
     137         countedFunctions.add(m_functionName.rep());
     138
     139        printf("%.0f %s\n", sampleCount ? sampleCount : 1, name);
    137140    } else
    138         printf("%s\n", m_functionName.UTF8String().c_str());
     141        printf("%s\n", name);
    139142
    140143    ++indentLevel;
    141144
    142145    // Print children's names and information
    143     double sumOfChildrensTimes = 0.0;
     146    double sumOfChildrensCount = 0.0;
    144147    for (StackIterator currentChild = m_children.begin(); currentChild != m_children.end(); ++currentChild)
    145         sumOfChildrensTimes += (*currentChild)->printDataSampleStyle(indentLevel);
     148        sumOfChildrensCount += (*currentChild)->printDataSampleStyle(indentLevel, countedFunctions);
    146149
    147     // Print remainder of time to match sample's output
    148     if (sumOfChildrensTimes < m_timeSum) {
     150    sumOfChildrensCount *= 1000;    //
     151    // Print remainder of samples to match sample's output
     152    if (sumOfChildrensCount < sampleCount) {
    149153        printf("    ");
    150154        while (indentLevel--)
    151155            printf("  ");
    152156
    153         printf("%f %s\n", m_timeSum - sumOfChildrensTimes, m_functionName.UTF8String().c_str());
     157        printf("%.0f %s\n", sampleCount - sumOfChildrensCount, m_functionName.UTF8String().c_str());
    154158    }
    155159
Note: See TracChangeset for help on using the changeset viewer.