Skip to content

Commit

Permalink
Add --ignore-external-source-id option to display-sampling-profiler-o…
Browse files Browse the repository at this point in the history
…utput

https://bugs.webkit.org/show_bug.cgi?id=264131
rdar://117887932

Reviewed by Justin Michaud.

Add --ignore-external-source-id option, which corresponds to samplingProfilerIgnoreExternalSourceID in JSC option.
It ignores source ID when unifying samples.

* Tools/Scripts/display-sampling-profiler-output:

Canonical link: https://commits.webkit.org/270158@main
  • Loading branch information
Constellation committed Nov 3, 2023
1 parent 1457c8d commit 7ae51b2
Showing 1 changed file with 29 additions and 7 deletions.
36 changes: 29 additions & 7 deletions Tools/Scripts/display-sampling-profiler-output
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
# THE POSSIBILITY OF SUCH DAMAGE.

require 'rubygems'

require 'readline'
require 'getoptlong'

begin
require 'json'
Expand All @@ -39,9 +38,18 @@ rescue LoadError
exit 1
end


$samplingProfilerIgnoreExternalSourceID = false
$samplingProfilerTopFunctionsCount = 12
$samplingProfilerTopBytecodesCount = 40
$json = JSON::parse(IO::read(ARGV[0]))

GetoptLong.new(['--ignore-external-source-id', '-s', GetoptLong::NO_ARGUMENT]).each {
| opt, arg |
case opt
when '--ignore-external-source-id'
$samplingProfilerIgnoreExternalSourceID = true
end
}

def reportTopFunctions database
totalSamples = 0
Expand All @@ -50,7 +58,10 @@ def reportTopFunctions database
next if stackTrace["frames"].empty?
frame = stackTrace["frames"][0]
hash, category, offset = frame["location"].split(":")
description = "#{frame["name"]}#{hash}:#{frame["sourceID"]}"
description = "#{frame["name"]}#{hash}"
unless $samplingProfilerIgnoreExternalSourceID
description = "#{description}:#{frame["sourceID"]}"
end
functionCounts[description] += 1
totalSamples += 1
end
Expand Down Expand Up @@ -152,6 +163,17 @@ def reportTopBytecodes database
end
end

reportTopFunctions($json)
puts ""
reportTopBytecodes($json)
def main
json = nil
if ARGV.empty?
json = JSON.parse(STDIN.read)
else
json = JSON::parse(IO::read(ARGV[0]))
end

reportTopFunctions(json)
puts ""
reportTopBytecodes(json)
end

main

0 comments on commit 7ae51b2

Please sign in to comment.