Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add script to analyze installer log for action run times #989

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions bin/installer-profile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env ruby

log = File.read(ARGV[0])

tasks = log.split("\n").select do |line|
line.include?('Evaluated in')
end

profile = []

#2021-04-27 01:13:35 [DEBUG ] [configure] /Stage[main]/Foreman/Foreman::Rake[apipie:cache:index]/Exec[foreman-rake-apipie:cache:index]: Evaluated in 86.60 seconds
tasks.each do |task|
EVALTRACE = %r{.+/(?<resource>.+\]): Evaluated in (?<time>\d+\.\d+) seconds}

evaltrace = EVALTRACE.match(task)
next if evaltrace.nil?
profile << {:task => evaltrace[:resource], :time => evaltrace[:time].to_f}
end

profile.sort! { |a,b| b[:time] <=> a[:time] }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer sort_by when I can

Suggested change
profile.sort! { |a,b| b[:time] <=> a[:time] }
profile.sort_by! { |p| p[:time] }


profile[0...15].each do |task|
puts "#{task[:time]}: #{task[:task]}"
end
Loading