Skip to content

Instantly share code, notes, and snippets.

@kares
Created May 7, 2026 09:51
Show Gist options
  • Select an option

  • Save kares/c4616956570fd58515ad6f0ffd822f8f to your computer and use it in GitHub Desktop.

Select an option

Save kares/c4616956570fd58515ad6f0ffd822f8f to your computer and use it in GitHub Desktop.
numbers for Java "block-to-interface" improvements: https://github.com/jruby/jruby/pull/9401
jruby 10.0.5.0 (3.4.5) 2026-04-06 5db1ba72f3 Java HotSpot(TM) 64-Bit Server VM 21.0.9+7-LTS-338 on 21.0.9+7-LTS-338 +indy +jit [x86_64-linux]
----- single-threaded -----
Rehearsal ---------------------------------------------------------------------------
Supplier Optional#orElseGet 12.350000 0.440000 12.790000 ( 6.153782)
Function Optional#map 10.320000 0.300000 10.620000 ( 6.399324)
Predicate Optional#filter 9.130000 0.220000 9.350000 ( 5.944928)
IntConsumer OptionalInt#ifPresent 9.010000 0.230000 9.240000 ( 5.622397)
DoubleSupplier OptionalDouble#orElseGet 9.990000 0.180000 10.170000 ( 5.743960)
BiFunction Map#compute 9.050000 0.110000 9.160000 ( 5.596288)
BiFunction Map#computeIfPresent 8.960000 0.150000 9.110000 ( 5.528440)
ToLongFunction Comparator.comparingLong 10.600000 0.170000 10.770000 ( 5.804415)
Comparator ArrayList#sort 10.590000 0.210000 10.800000 ( 6.699945)
----------------------------------------------------------------- total: 92.010000sec
user system total real
Supplier Optional#orElseGet 9.550000 0.130000 9.680000 ( 5.900849)
Function Optional#map 9.220000 0.110000 9.330000 ( 5.961464)
Predicate Optional#filter 10.080000 0.170000 10.250000 ( 6.110982)
IntConsumer OptionalInt#ifPresent 9.270000 0.140000 9.410000 ( 5.581016)
DoubleSupplier OptionalDouble#orElseGet 9.400000 0.120000 9.520000 ( 5.660555)
BiFunction Map#compute 9.470000 0.140000 9.610000 ( 5.740828)
BiFunction Map#computeIfPresent 9.290000 0.130000 9.420000 ( 5.625369)
ToLongFunction Comparator.comparingLong 9.450000 0.150000 9.600000 ( 5.649786)
Comparator ArrayList#sort 9.850000 0.150000 10.000000 ( 6.363995)
----- multi-threaded (4 submitter threads, N tasks each) -----
Rehearsal ------------------------------------------------------------------------------------
Consumer Optional#ifPresent (4 threads) 20.650000 1.260000 21.910000 ( 5.810558)
Consumer Optional#ifPresent (16 threads) 24.960000 1.580000 26.540000 ( 7.364534)
Consumer Optional#ifPresent (128 threads) 25.980000 1.750000 27.730000 ( 7.629335)
IntConsumer OptionalInt#ifPresent (4 threads) 18.950000 1.140000 20.090000 ( 5.201955)
IntConsumer OptionalInt#ifPresent (128 threads) 26.050000 1.650000 27.700000 ( 7.753672)
IntConsumer OptionalInt#ifPresent (512 threads) 26.970000 1.950000 28.920000 ( 7.873137)
Comparator List#stream.sorted (16 threads) 29.390000 1.900000 31.290000 ( 8.418670)
Comparator List#stream.sorted (128 threads) 29.730000 1.850000 31.580000 ( 8.661570)
Comparator List#stream.sorted (512 threads) 30.330000 2.040000 32.370000 ( 8.787624)
------------------------------------------------------------------------- total: 248.130000sec
user system total real
Consumer Optional#ifPresent (4 threads) 20.630000 1.390000 22.020000 ( 5.912398)
Consumer Optional#ifPresent (16 threads) 25.150000 1.690000 26.840000 ( 7.536060)
Consumer Optional#ifPresent (128 threads) 27.390000 1.720000 29.110000 ( 8.031584)
IntConsumer OptionalInt#ifPresent (4 threads) 19.410000 1.120000 20.530000 ( 5.417282)
IntConsumer OptionalInt#ifPresent (128 threads) 26.140000 1.710000 27.850000 ( 7.756989)
IntConsumer OptionalInt#ifPresent (512 threads) 26.260000 1.870000 28.130000 ( 7.825643)
Comparator List#stream.sorted (16 threads) 28.520000 1.910000 30.430000 ( 8.465622)
Comparator List#stream.sorted (128 threads) 29.830000 1.910000 31.740000 ( 8.772469)
Comparator List#stream.sorted (512 threads) 30.870000 2.100000 32.970000 ( 8.951590)
bin/jruby -v bench/java/bench_block_to_interface.rb
jruby 10.0.6.0-SNAPSHOT (3.4.5) 2026-05-07 128b86d00d Java HotSpot(TM) 64-Bit Server VM 21.0.9+7-LTS-338 on 21.0.9+7-LTS-338 +indy +jit [x86_64-linux]
----- single-threaded -----
Rehearsal ---------------------------------------------------------------------------
Supplier Optional#orElseGet 1.700000 0.080000 1.780000 ( 0.447995)
Function Optional#map 0.860000 0.020000 0.880000 ( 0.413161)
Predicate Optional#filter 0.450000 0.000000 0.450000 ( 0.315053)
IntConsumer OptionalInt#ifPresent 0.380000 0.030000 0.410000 ( 0.197425)
DoubleSupplier OptionalDouble#orElseGet 0.360000 0.000000 0.360000 ( 0.193833)
BiFunction Map#compute 0.560000 0.000000 0.560000 ( 0.195098)
BiFunction Map#computeIfPresent 0.370000 0.010000 0.380000 ( 0.162080)
ToLongFunction Comparator.comparingLong 0.720000 0.020000 0.740000 ( 0.303436)
Comparator ArrayList#sort 0.200000 0.000000 0.200000 ( 0.131115)
------------------------------------------------------------------ total: 5.760000sec
user system total real
Supplier Optional#orElseGet 0.280000 0.000000 0.280000 ( 0.254504)
Function Optional#map 0.340000 0.010000 0.350000 ( 0.333915)
Predicate Optional#filter 0.310000 0.000000 0.310000 ( 0.299424)
IntConsumer OptionalInt#ifPresent 0.110000 0.000000 0.110000 ( 0.103770)
DoubleSupplier OptionalDouble#orElseGet 0.180000 0.010000 0.190000 ( 0.165599)
BiFunction Map#compute 0.140000 0.000000 0.140000 ( 0.132204)
BiFunction Map#computeIfPresent 0.120000 0.000000 0.120000 ( 0.116253)
ToLongFunction Comparator.comparingLong 0.200000 0.000000 0.200000 ( 0.190727)
Comparator ArrayList#sort 0.120000 0.000000 0.120000 ( 0.111760)
----- multi-threaded (4 submitter threads, N tasks each) -----
Rehearsal ------------------------------------------------------------------------------------
Consumer Optional#ifPresent (4 threads) 0.700000 0.010000 0.710000 ( 0.130152)
Consumer Optional#ifPresent (16 threads) 1.070000 0.010000 1.080000 ( 0.069462)
Consumer Optional#ifPresent (128 threads) 1.170000 0.030000 1.200000 ( 0.061818)
IntConsumer OptionalInt#ifPresent (4 threads) 0.360000 0.000000 0.360000 ( 0.078786)
IntConsumer OptionalInt#ifPresent (128 threads) 1.250000 0.090000 1.340000 ( 0.066608)
IntConsumer OptionalInt#ifPresent (512 threads) 1.280000 0.070000 1.350000 ( 0.075610)
Comparator List#stream.sorted (16 threads) 2.890000 0.020000 2.910000 ( 0.174388)
Comparator List#stream.sorted (128 threads) 1.690000 0.020000 1.710000 ( 0.084521)
Comparator List#stream.sorted (512 threads) 1.620000 0.070000 1.690000 ( 0.087313)
-------------------------------------------------------------------------- total: 12.350000sec
user system total real
Consumer Optional#ifPresent (4 threads) 0.360000 0.000000 0.360000 ( 0.089295)
Consumer Optional#ifPresent (16 threads) 0.530000 0.080000 0.610000 ( 0.052276)
Consumer Optional#ifPresent (128 threads) 0.590000 0.020000 0.610000 ( 0.036124)
IntConsumer OptionalInt#ifPresent (4 threads) 0.170000 0.000000 0.170000 ( 0.042637)
IntConsumer OptionalInt#ifPresent (128 threads) 0.310000 0.010000 0.320000 ( 0.020472)
IntConsumer OptionalInt#ifPresent (512 threads) 0.270000 0.040000 0.310000 ( 0.033094)
Comparator List#stream.sorted (16 threads) 0.550000 0.130000 0.680000 ( 0.051915)
Comparator List#stream.sorted (128 threads) 0.730000 0.010000 0.740000 ( 0.042363)
Comparator List#stream.sorted (512 threads) 0.680000 0.060000 0.740000 ( 0.047790)
jruby 9.4.14.0 (3.1.7) 2025-08-28 ddda6d5992 Java HotSpot(TM) 64-Bit Server VM 21.0.9+7-LTS-338 on 21.0.9+7-LTS-338 +jit [x86_64-linux]
----- single-threaded -----
Rehearsal ---------------------------------------------------------------------------
Supplier Optional#orElseGet 14.890000 0.590000 15.480000 ( 7.202944)
Function Optional#map 14.810000 0.380000 15.190000 ( 7.843529)
Predicate Optional#filter 12.950000 0.220000 13.170000 ( 7.223983)
IntConsumer OptionalInt#ifPresent 13.860000 0.250000 14.110000 ( 7.394776)
DoubleSupplier OptionalDouble#orElseGet 12.860000 0.260000 13.120000 ( 7.407366)
BiFunction Map#compute 15.510000 0.220000 15.730000 ( 7.653281)
BiFunction Map#computeIfPresent 12.540000 0.140000 12.680000 ( 7.045854)
ToLongFunction Comparator.comparingLong 16.010000 0.260000 16.270000 ( 7.689245)
Comparator ArrayList#sort 14.780000 0.180000 14.960000 ( 8.027676)
---------------------------------------------------------------- total: 130.710000sec
user system total real
Supplier Optional#orElseGet 13.050000 0.120000 13.170000 ( 7.112831)
Function Optional#map 15.050000 0.150000 15.200000 ( 7.657151)
Predicate Optional#filter 12.640000 0.130000 12.770000 ( 7.278135)
IntConsumer OptionalInt#ifPresent 15.090000 0.180000 15.270000 ( 7.265956)
DoubleSupplier OptionalDouble#orElseGet 12.980000 0.130000 13.110000 ( 7.016826)
BiFunction Map#compute 12.810000 0.120000 12.930000 ( 7.040107)
BiFunction Map#computeIfPresent 15.250000 0.180000 15.430000 ( 7.401830)
ToLongFunction Comparator.comparingLong 13.030000 0.130000 13.160000 ( 6.903220)
Comparator ArrayList#sort 13.800000 0.130000 13.930000 ( 7.488045)
----- multi-threaded (4 submitter threads, N tasks each) -----
Rehearsal ------------------------------------------------------------------------------------
Consumer Optional#ifPresent (4 threads) 23.030000 1.040000 24.070000 ( 5.937423)
Consumer Optional#ifPresent (16 threads) 30.020000 1.740000 31.760000 ( 8.330956)
Consumer Optional#ifPresent (128 threads) 33.600000 1.770000 35.370000 ( 8.870221)
IntConsumer OptionalInt#ifPresent (4 threads) 23.840000 1.120000 24.960000 ( 6.156736)
IntConsumer OptionalInt#ifPresent (128 threads) 33.760000 1.810000 35.570000 ( 9.017025)
IntConsumer OptionalInt#ifPresent (512 threads) 30.710000 1.930000 32.640000 ( 8.513337)
Comparator List#stream.sorted (16 threads) 33.440000 1.840000 35.280000 ( 8.947922)
Comparator List#stream.sorted (128 threads) 35.260000 1.970000 37.230000 ( 9.494942)
Comparator List#stream.sorted (512 threads) 36.590000 2.020000 38.610000 ( 9.602585)
------------------------------------------------------------------------- total: 295.490000sec
user system total real
Consumer Optional#ifPresent (4 threads) 23.590000 1.170000 24.760000 ( 6.184394)
Consumer Optional#ifPresent (16 threads) 29.690000 1.710000 31.400000 ( 8.246733)
Consumer Optional#ifPresent (128 threads) 33.410000 1.700000 35.110000 ( 8.870957)
IntConsumer OptionalInt#ifPresent (4 threads) 24.680000 1.320000 26.000000 ( 6.621133)
IntConsumer OptionalInt#ifPresent (128 threads) 34.550000 1.870000 36.420000 ( 9.183393)
IntConsumer OptionalInt#ifPresent (512 threads) 31.320000 1.810000 33.130000 ( 8.601747)
Comparator List#stream.sorted (16 threads) 33.060000 1.710000 34.770000 ( 8.863973)
Comparator List#stream.sorted (128 threads) 36.510000 1.910000 38.420000 ( 9.666467)
Comparator List#stream.sorted (512 threads) 35.010000 2.020000 37.030000 ( 9.508334)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment