Class: PerfLab::Util

Inherits:
Object
  • Object
show all
Defined in:
lib/perflab/util.rb

Class Method Summary collapse

Class Method Details



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/perflab/util.rb', line 4

def print_performance_improvement(existing_result, improved_result)
  percentage = ((improved_result.to_f - existing_result.to_f) / existing_result.to_f) * 100

  if percentage < 0
    puts "Improved is #{percentage.abs.round(2)}% faster"
  elsif percentage > 0
    puts "Improved is #{percentage.abs.round(2)}% slower"
  else
    puts 'No difference in speed'
  end
end