Skip to content

Commit

Permalink
Merge 162fa7c into a90115a
Browse files Browse the repository at this point in the history
  • Loading branch information
sfgeorge committed Jul 20, 2019
2 parents a90115a + 162fa7c commit cf6f0cf
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions features/support/env.rb
Expand Up @@ -29,3 +29,20 @@
set_env('JAVA_OPTS', "#{ENV['JAVA_OPTS']} #{JAVA_OPTS_SAVED}")
end
end if RUBY_PLATFORM == 'java'

# Profile slowest features
# @see https://itshouldbeuseful.wordpress.com/2010/11/10/find-your-slowest-running-cucumber-features/
scenario_times = {}
Around() do |scenario, block|
start = Time.now
block.call
scenario_times["#{scenario.feature.file}::#{scenario.name}"] = Time.now - start
end
at_exit do
max_scenarios = scenario_times.size > 30 ? 30 : scenario_times.size
puts "------------- Top #{max_scenarios} slowest scenarios -------------"
sorted_times = scenario_times.sort { |a, b| b[1] <=> a[1] }
sorted_times[0..max_scenarios - 1].each do |key, value|
puts "#{value.round(2)} #{key}"
end
end

0 comments on commit cf6f0cf

Please sign in to comment.