Skip to content

Commit

Permalink
Fix for 1.8
Browse files Browse the repository at this point in the history
  • Loading branch information
justinko committed Apr 18, 2012
1 parent 4d9472e commit 1c0ce8d
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/rspec/core/formatters/base_text_formatter.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -52,10 +52,13 @@ def dump_commands_to_rerun_failed_examples
end end


def dump_profile def dump_profile
sorted_examples = examples.sort_by { |example| example.execution_result[:run_time] }.reverse.first(10) sorted_examples = examples.sort_by {|example|
example.execution_result[:run_time] }.reverse.first(10)


total, slows = [examples, sorted_examples].map {|exs| exs.inject(0.0) {|i, e| i + e.execution_result[:run_time] } } total, slows = [examples, sorted_examples].map {|exs|
output.puts "\nTop #{sorted_examples.size} slowest examples (#{format_seconds(slows)} seconds, #{((slows / total) * 100).round(2)}% of total time):\n" exs.inject(0.0) {|i, e| i + e.execution_result[:run_time] }}

output.puts "\nTop #{sorted_examples.size} slowest examples (#{format_seconds(slows)} seconds, #{'%.1f' % ((slows / total) * 100)}% of total time):\n"


sorted_examples.each do |example| sorted_examples.each do |example|
output.puts " #{example.full_description}" output.puts " #{example.full_description}"
Expand Down

0 comments on commit 1c0ce8d

Please sign in to comment.