Skip to content

Instantly share code, notes, and snippets.

@lsylvester
Created October 5, 2010 03:34
Show Gist options
  • Save lsylvester/610941 to your computer and use it in GitHub Desktop.
Save lsylvester/610941 to your computer and use it in GitHub Desktop.
require 'benchmark'
include Benchmark
var = (1..100).to_a
bm do |x|
x.report { 1000000.times { var[1, var.length] } }
x.report { 1000000.times { var[1..-1] } }
end
__END__
user system total real
0.330000 0.000000 0.330000 ( 0.329509)
0.310000 0.000000 0.310000 ( 0.310516)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment