Skip to content

Instantly share code, notes, and snippets.

@capotej
Created August 3, 2009 17:06
Show Gist options
  • Save capotej/160693 to your computer and use it in GitHub Desktop.
Save capotej/160693 to your computer and use it in GitHub Desktop.
#cdr in ruby benchmarks
require 'benchmark'
arr = (0...1000).to_a
puts Benchmark.measure { 10000.times { arr.values_at(1..-1) } }
# 0.570000 0.010000 0.580000 ( 0.586325)
puts Benchmark.measure { 10000.times { arr.slice(1..-1) } }
# 0.020000 0.000000 0.020000 ( 0.012761)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment