Changeset 269597 in webkit


Ignore:
Timestamp:
Nov 9, 2020 1:18:08 PM (3 years ago)
Author:
keith_miller@apple.com
Message:

Add total counts to sampling profiler dump
https://bugs.webkit.org/show_bug.cgi?id=218666

Reviewed by Yusuke Suzuki.

This is nice for computing the approximate percentage of total time in a function.

  • runtime/SamplingProfiler.cpp:

(JSC::SamplingProfiler::reportTopFunctions):
(JSC::SamplingProfiler::reportTopBytecodes):

Location:
trunk/Source/JavaScriptCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r269576 r269597  
     12020-11-09  Keith Miller  <keith_miller@apple.com>
     2
     3        Add total counts to sampling profiler dump
     4        https://bugs.webkit.org/show_bug.cgi?id=218666
     5
     6        Reviewed by Yusuke Suzuki.
     7
     8        This is nice for computing the approximate percentage of total time in a function.
     9
     10        * runtime/SamplingProfiler.cpp:
     11        (JSC::SamplingProfiler::reportTopFunctions):
     12        (JSC::SamplingProfiler::reportTopBytecodes):
     13
    1142020-11-08  Yusuke Suzuki  <ysuzuki@apple.com>
    215
  • trunk/Source/JavaScriptCore/runtime/SamplingProfiler.cpp

    r268077 r269597  
    10241024    }
    10251025
    1026 
     1026    size_t totalSamples = 0;
    10271027    HashMap<String, size_t> functionCounts;
    10281028    for (StackTrace& stackTrace : m_stackTraces) {
     
    10401040        String frameDescription = makeString(frame.displayName(m_vm), '#', hash, ':', frame.sourceID());
    10411041        functionCounts.add(frameDescription, 0).iterator->value++;
     1042        totalSamples++;
    10421043    }
    10431044
     
    10571058
    10581059    if (Options::samplingProfilerTopFunctionsCount()) {
    1059         out.print("\n\nSampling rate: ", m_timingInterval.microseconds(), " microseconds\n");
    1060         out.print("Top functions as <numSamples  'functionName#hash:sourceID'>\n");
     1060        out.println("\n\nSampling rate: ", m_timingInterval.microseconds(), " microseconds. Total samples: ", totalSamples);
     1061        out.println("Top functions as <numSamples  'functionName#hash:sourceID'>");
    10611062        for (size_t i = 0; i < Options::samplingProfilerTopFunctionsCount(); i++) {
    10621063            auto pair = takeMax();
     
    10641065                break;
    10651066            out.printf("%6zu ", pair.second);
    1066             out.print("   '", pair.first, "'\n");
     1067            out.println("   '", pair.first, "'");
    10671068        }
    10681069    }
     
    10841085    }
    10851086
     1087    size_t totalSamples = 0;
    10861088    HashMap<String, size_t> bytecodeCounts;
    10871089    for (StackTrace& stackTrace : m_stackTraces) {
     
    11201122        }
    11211123        bytecodeCounts.add(frameDescription, 0).iterator->value++;
     1124        totalSamples++;
    11221125    }
    11231126
     
    11371140
    11381141    if (Options::samplingProfilerTopBytecodesCount()) {
    1139         out.print("\n\nSampling rate: ", m_timingInterval.microseconds(), " microseconds\n");
    1140         out.print("Hottest bytecodes as <numSamples   'functionName#hash:JITType:bytecodeIndex'>\n");
     1142        out.println("\n\nSampling rate: ", m_timingInterval.microseconds(), " microseconds. Total samples: ", totalSamples);
     1143        out.println("Hottest bytecodes as <numSamples   'functionName#hash:JITType:bytecodeIndex'>");
    11411144        for (size_t i = 0; i < Options::samplingProfilerTopBytecodesCount(); i++) {
    11421145            auto pair = takeMax();
     
    11441147                break;
    11451148            out.printf("%6zu ", pair.second);
    1146             out.print("   '", pair.first, "'\n");
     1149            out.println("   '", pair.first, "'");
    11471150        }
    11481151    }
Note: See TracChangeset for help on using the changeset viewer.