Skip to content

Instantly share code, notes, and snippets.

@francescoagati
Created December 9, 2012 00:38
Show Gist options
  • Save francescoagati/4242761 to your computer and use it in GitHub Desktop.
Save francescoagati/4242761 to your computer and use it in GitHub Desktop.
simple sort benchmarking between jruby 1.7.1 and ruby 1.9.3
require 'benchmark'
array = (1..100000).map { rand }
Benchmark.bmbm do |x|
x.report("sort!") { (0..20).each { array.dup.sort! } }
x.report("sort") { (0..20).each { array.dup.sort! } }
end
ruby 1.9.3
Rehearsal -----------------------------------------
sort! 4.170000 0.010000 4.180000 ( 4.183763)
sort 4.190000 0.000000 4.190000 ( 4.202959)
-------------------------------- total: 8.370000sec
user system total real
sort! 4.140000 0.010000 4.150000 ( 4.154430)
sort 4.130000 0.000000 4.130000 ( 4.140072)
jruby 1.7.1
Rehearsal -----------------------------------------
sort! 1.800000 0.010000 1.810000 ( 1.585000)
sort 1.370000 0.020000 1.390000 ( 1.366000)
-------------------------------- total: 3.200000sec
user system total real
sort! 1.320000 0.000000 1.320000 ( 1.327000)
sort 1.330000 0.020000 1.350000 ( 1.351000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment