Created
November 20, 2015 16:15
-
-
Save yorickpeterse/ec274c38c8160bb1a4a1 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
Calculating ------------------------------------- | |
Array#[] 201.052k i/100ms | |
Array#at 194.228k i/100ms | |
------------------------------------------------- | |
Array#[] 11.090M (± 2.2%) i/s - 55.490M | |
Array#at 10.003M (± 1.3%) i/s - 50.111M | |
Comparison: | |
Array#[]: 11089538.6 i/s | |
Array#at: 10002944.7 i/s - 1.11x slower |
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
require 'benchmark/ips' | |
array = (1..1_000_000).to_a | |
Benchmark.ips do |bench| | |
bench.report 'Array#[]' do | |
array[4] | |
end | |
bench.report 'Array#at' do | |
array.at(4) | |
end | |
bench.compare! | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment