Create a gist now

Instantly share code, notes, and snippets.

@kares /bench.rb Secret
Last active Apr 14, 2016

What would you like to do?
Java extension performance comparison on JRuby 1.7.24 / 9.0.5.0 / 9.1.x.x
require 'java'
require 'benchmark'
TIMES = (ARGV[0] || 5).to_i
TIMES.times do
Benchmark.bm(10) do |bm|
bm.report('List') do
list = java.util.ArrayList.new
one = 1.to_java
two = 2.to_java
thr = 3.to_java
1_000_000.times do
list.clear
list << one; list << two; list << thr
list[2] = one
list[0] = two
list[1] = thr
list.index(one)
list.rindex(thr)
end
end
end
end
#### 1.7.24
user system total real
List 8.710000 1.400000 10.110000 ( 7.017000)
user system total real
List 6.920000 0.130000 7.050000 ( 6.047000)
user system total real
List 6.780000 0.060000 6.840000 ( 5.830000)
user system total real
List 6.250000 0.070000 6.320000 ( 5.453000)
user system total real
List 6.690000 0.130000 6.820000 ( 5.718000)
#### 9.0.5.0
user system total real
List 6.990000 0.960000 7.950000 ( 6.189472)
user system total real
List 4.440000 0.170000 4.610000 ( 4.554358)
user system total real
List 4.200000 0.000000 4.200000 ( 4.186065)
user system total real
List 4.500000 0.010000 4.510000 ( 4.482301)
user system total real
List 4.690000 0.000000 4.690000 ( 4.677239)
#### 9.1.x.x
user system total real
List 2.910000 0.390000 3.300000 ( 2.070244)
user system total real
List 1.290000 0.030000 1.320000 ( 1.276111)
user system total real
List 1.290000 0.240000 1.530000 ( 1.529822)
user system total real
List 1.240000 0.280000 1.520000 ( 1.473230)
user system total real
List 1.170000 0.070000 1.240000 ( 1.164659)
#### 1.7.24
user system total real
List 17.100000 1.170000 18.270000 ( 15.903000)
user system total real
List 16.660000 0.010000 16.670000 ( 15.061000)
user system total real
List 17.350000 0.010000 17.360000 ( 15.937000)
user system total real
List 18.040000 0.000000 18.040000 ( 16.552000)
user system total real
List 15.410000 0.000000 15.410000 ( 13.922000)
#### 9.0.5.0
user system total real
List 20.820000 0.840000 21.660000 ( 20.724984)
user system total real
List 15.370000 0.300000 15.670000 ( 15.357027)
user system total real
List 14.450000 0.250000 14.700000 ( 14.491476)
user system total real
List 22.350000 0.060000 22.410000 ( 22.335163)
user system total real
List 13.270000 0.000000 13.270000 ( 13.245202)
#### 9.1.x.x
user system total real
List 5.180000 0.190000 5.370000 ( 5.068730)
user system total real
List 3.280000 0.530000 3.810000 ( 3.705552)
user system total real
List 3.190000 0.750000 3.940000 ( 3.940179)
user system total real
List 3.200000 0.050000 3.250000 ( 3.195196)
user system total real
List 3.160000 0.020000 3.180000 ( 3.151076)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment