Skip to content
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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
#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
# 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

EVALTRACE = %r{.+/(?<resource>.+\[.+\]): Evaluated in (?<time>\d+\.\d+) seconds}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
EVALTRACE = %r{.+/(?<resource>.+\[.+\]): Evaluated in (?<time>\d+\.\d+) seconds}
EVALTRACE = %r{.+/(?<resource>.+\[.+\]): Evaluated in (?<time>\d+\.\d+) seconds}.freeze


tasks.each do |task|
evaltrace = EVALTRACE.match(task)
next if evaltrace.nil?
profile << {:task => evaltrace[:resource], :time => evaltrace[:time].to_f}
Comment on lines +16 to +17

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
next if evaltrace.nil?
profile << {:task => evaltrace[:resource], :time => evaltrace[:time].to_f}
next if evaltrace.nil?
profile << { :task => evaltrace[:resource], :time => evaltrace[:time].to_f }

end

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

Copy link
Copy Markdown
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