Created
August 11, 2024 06:21
-
-
Save paderinandrey/a5278118a455872186f995a021523fcc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'debug' | |
target = ENV.fetch('TARGET', 'spec/requests') | |
run :event_prof, event: 'factory.create', top_count: 10, paths: target, rank_by: :time | |
total_run_time = report.raw_report['absolute_run_time'] | |
total_event_time = report.raw_report['total_time'] | |
threshold = 0.5 * total_run_time | |
sum = 0.0 | |
sum_event = 0.0 | |
top_groups = report.raw_report['groups'].take_while do |group| | |
next false unless sum < threshold | |
sum += group['run_time'] | |
sum_event += group['time'] | |
true | |
end | |
msg = <<~TXT | |
Total groups: #{report.raw_report['groups'].size} | |
Total times: #{total_event_time} / #{total_run_time} | |
Selected groups: #{top_groups.size} | |
Selected times: #{sum_event} / #{sum} | |
Paths: | |
TXT | |
paths = top_groups.map { _1['location'] } | |
puts msg | |
puts paths.join("\n") | |
puts 'RUN factory_prof ...' | |
run :factory_prof, paths: report.paths, top_count: 10, rank_by: :time | |
puts 'RUN factory_default_prof ...' | |
ractors = [] | |
results = {} | |
paths.map do |path| | |
run :factory_default_prof, paths: path, rank_by: :count | |
results[path] = report | |
end | |
results.each do |path, report| | |
next if report.raw_report.empty? | |
puts path | |
info(report) | |
puts "\n" * 2 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment