Skip to content

Instantly share code, notes, and snippets.

@eregon
Last active February 7, 2019 10:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eregon/48e7966b270dc03b362a49ae8497d693 to your computer and use it in GitHub Desktop.
Save eregon/48e7966b270dc03b362a49ae8497d693 to your computer and use it in GitHub Desktop.
Analyse RVM --trace output
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