Skip to content

Commit

Permalink
Merge pull request #123 from ywenc/separate_file_vs_formatting
Browse files Browse the repository at this point in the history
Separate parsing samples_by_file from output
  • Loading branch information
jhawthorn authored Jan 24, 2025
2 parents 1b5cc15 + a95a6c8 commit 5d64993
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions lib/vernier/output/file_listing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,20 @@ def initialize(profile)
@profile = profile
end

def output
output = +""

def samples_by_file
thread = @profile.main_thread
if Hash === thread
# live profile
stack_table = @profile._stack_table
weights = thread[:weights]
samples = thread[:samples]
filename_filter = FilenameFilter.new
else
stack_table = thread.stack_table
weights = thread.weights
samples = thread.samples
filename_filter = ->(x) { x }
end

weights = thread[:weights]
samples = thread[:samples]

self_samples_by_frame = Hash.new do |h, k|
h[k] = SamplesByLocation.new
end
Expand Down Expand Up @@ -76,6 +73,10 @@ def output
samples_by_file.transform_keys! do |filename|
filename_filter.call(filename)
end
end

def output
output = +""

relevant_files = samples_by_file.select do |k, v|
next if k.start_with?("gem:")
Expand All @@ -92,6 +93,11 @@ def output
output << "="*80 << "\n"
end

def total
thread = @profile.main_thread
thread[:weights].sum
end

def format_file(output, filename, all_samples, total:)
samples = all_samples[filename]

Expand Down

0 comments on commit 5d64993

Please sign in to comment.