-
-
Save phcostabh/9762110 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
type = :info | |
time = Time.now | |
2_000_000.times do | |
msg = case type | |
when :success then 'alert-success' | |
when :error then 'alert-danger' | |
when :warn then 'alert-warning' | |
when :info then 'alert-info' | |
end | |
end | |
puts "case: #{Time.now - time}" | |
time = Time.now | |
2_000_000.times do | |
msg = if type == :success then 'alert-success' | |
elsif type == :error then 'alert-danger' | |
elsif type == :warn then 'alert-warning' | |
elsif type == :info then 'alert-info' | |
end | |
end | |
puts "if: #{Time.now - time}" | |
time = Time.now | |
msg = { | |
success: 'alert-success', | |
error: 'alert-danger', | |
notice: 'alert-info', | |
warn: 'alert-warning' | |
} | |
2_000_000.times do | |
msg[type] | |
end | |
puts "hash: #{Time.now - time}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment