Created
June 18, 2014 11:09
-
-
Save solutus/74d0c353a83bbb8d8f64 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
#!/usr/bin/env ruby | |
# Simple script, sorting tests by duration to analyze slow tests. | |
# Usage: | |
# chmod +x sort_tests.sh | |
# rspec -f d spec/ | sort_tests.sh | |
data = [] | |
prev_time = nil | |
while input = ARGF.gets | |
input.each_line do |line| | |
time_diff = ((Time.now - (prev_time || Time.now)) * 1000).to_i | |
prev_time = Time.now | |
data << [time_diff, line] | |
end | |
end | |
data = data.sort_by { |x| x[0] } | |
begin | |
data.each do |diff, line| | |
$stdout.puts [diff, line].join("\t") | |
end | |
$stdout.puts "total time: #{data.map {|x| x[0]}.inject(&:+)} ms" | |
rescue Errno::EPIPE | |
exit(74) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment