Last active
February 7, 2019 10:23
-
-
Save eregon/48e7966b270dc03b362a49ae8497d693 to your computer and use it in GitHub Desktop.
Analyse RVM --trace output
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
lines = File.readlines(ARGV[0], chomp: true) | |
min_time = Float(ARGV[1] || 1.0) | |
data = lines.grep(/^[+]+\s*(\d+\.\d+)/).map { |line| | |
line =~ /^[+]+\s*(\d+\.\d+)/ or raise line | |
[Float($1), $'] | |
} | |
class Float | |
def to_s | |
format("%.2f", self) | |
end | |
end | |
puts "Total time: #{data.last[0] - data.first[0]}" | |
long = data.each_cons(2).select { |(t1,c1),(t2,c2)| | |
t2 - t1 >= min_time | |
}.map { |(t1,c1),(t2,c2)| | |
[t2-t1, c1] | |
} | |
long.each { |t,c| | |
puts "#{t}\t#{c}" | |
} | |
puts "Sum of times > #{min_time}s: #{long.sum(&:first)}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment