Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
require 'benchmark'
executions = 100_000_000
Benchmark.bm do |conditional_assignment|
conditional_assignment.report { executions.times do a ||= 1; end }
conditional_assignment.report { executions.times do a = a || 1; end }
end
=begin
user system total real
9.110000 0.000000 9.110000 ( 9.112874)
9.150000 0.000000 9.150000 ( 9.152972)
=end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.