Skip to content

Instantly share code, notes, and snippets.

@muga
Last active June 18, 2017 09:29
Show Gist options
  • Save muga/b83262ed03009d2f765f8fd0c5319e54 to your computer and use it in GitHub Desktop.
Save muga/b83262ed03009d2f765f8fd0c5319e54 to your computer and use it in GitHub Desktop.
Cache RubyDateParser object in ThreadContext to reduce the count of passing objects between RubyObject and Java
1,000 times Date._strptime('2001-02-03', '%Y-%m-%d')
user system total real
mri 2.4.1 0.000000 0.000000 0.070000 ( 0.092492)
jruby 9.1.9.0 0.000000 0.000000 8.220000 ( 3.861129)
jruby (master) 0.000000 0.000000 7.130000 ( 3.671143)
10,000 times Date._strptime('2001-02-03', '%Y-%m-%d')
user system total real
mri 2.4.1 0.000000 0.000000 0.100000 ( 0.126605)
jruby 9.1.9.0 0.000000 0.000000 11.570000 ( 5.183052)
jruby (master) 0.000000 0.000000 8.280000 ( 3.905535)
100,000 times Date._strptime('2001-02-03', '%Y-%m-%d')
user system total real
mri 2.4.1 0.000000 0.000000 0.200000 ( 0.219390)
jruby 9.1.9.0 0.000000 0.000000 17.000000 ( 10.131313)
jruby (master) 0.000000 0.000000 10.620000 ( 5.003686)
1,000,000 times Date._strptime('2001-02-03', '%Y-%m-%d')
user system total real
mri 2.4.1 0.000000 0.000000 1.240000 ( 1.361164)
jruby 9.1.9.0 0.000000 0.000000 57.490000 ( 51.720962)
jruby (master) 0.000000 0.000000 17.010000 ( 10.431316)
10,000,000 times Date._strptime('2001-02-03', '%Y-%m-%d')
user system total real
mri 2.4.1 0.000000 0.000000 12.750000 ( 15.315754)
jruby 9.1.9.0 0.000000 0.000000 525.980000 (586.105106)
jruby (master) 0.000000 0.000000 66.050000 ( 65.739327)
---
$ bench/run
======================environment======================
mri 2.4.1
command: ~/.rbenv/versions/2.4.1/bin/ruby
version: ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-darwin16]
jruby 9.1.9.0
command: ~/.rbenv/versions/jruby-9.1.9.0/bin/ruby
version: jruby 9.1.9.0 (2.3.3) 2017-05-15 28aa830 Java HotSpot(TM) 64-Bit Server VM 25.131-b11 on 1.8.0_131-b11 +jit [darwin-x86_64]
jruby (master)
command: /Users/muga/works/sources/jruby-jruby/bin/ruby
version: jruby 9.1.11.0-SNAPSHOT (2.3.3) 2017-05-26 83098f6 Java HotSpot(TM) 64-Bit Server VM 25.131-b11 on 1.8.0_131-b11 +jit [darwin-x86_64]
=============bench/strptime_Y-m-d_1000.rb==============
Rehearsal --------------------------------------------------
mri 2.4.1 0.000000 0.000000 0.070000 ( 0.096673)
jruby 9.1.9.0 0.000000 0.000000 8.110000 ( 3.897572)
jruby (master) 0.000000 0.000000 6.760000 ( 3.307310)
---------------------------------------- total: 14.940000sec
user system total real
mri 2.4.1 0.000000 0.000000 0.070000 ( 0.092492)
jruby 9.1.9.0 0.000000 0.000000 8.220000 ( 3.861129)
jruby (master) 0.000000 0.000000 7.130000 ( 3.671143)
=============bench/strptime_Y-m-d_10000.rb=============
Rehearsal --------------------------------------------------
mri 2.4.1 0.000000 0.000000 0.080000 ( 0.096134)
jruby 9.1.9.0 0.000000 0.000000 11.390000 ( 5.097575)
jruby (master) 0.000000 0.000000 7.830000 ( 3.818345)
---------------------------------------- total: 19.300000sec
user system total real
mri 2.4.1 0.000000 0.000000 0.100000 ( 0.126605)
jruby 9.1.9.0 0.000000 0.000000 11.570000 ( 5.183052)
jruby (master) 0.000000 0.000000 8.280000 ( 3.905535)
============bench/strptime_Y-m-d_100000.rb=============
Rehearsal --------------------------------------------------
mri 2.4.1 0.000000 0.000000 0.200000 ( 0.233093)
jruby 9.1.9.0 0.000000 0.000000 16.340000 ( 9.915780)
jruby (master) 0.000000 0.000000 10.150000 ( 4.933292)
---------------------------------------- total: 26.690000sec
user system total real
mri 2.4.1 0.000000 0.000000 0.200000 ( 0.219390)
jruby 9.1.9.0 0.000000 0.000000 17.000000 ( 10.131313)
jruby (master) 0.000000 0.000000 10.620000 ( 5.003686)
============bench/strptime_Y-m-d_1000000.rb============
Rehearsal --------------------------------------------------
mri 2.4.1 0.000000 0.000000 1.270000 ( 1.320873)
jruby 9.1.9.0 0.000000 0.000000 59.270000 ( 52.718241)
jruby (master) 0.000000 0.000000 15.590000 ( 10.074218)
---------------------------------------- total: 76.130000sec
user system total real
mri 2.4.1 0.000000 0.000000 1.240000 ( 1.361164)
jruby 9.1.9.0 0.000000 0.000000 57.490000 ( 51.720962)
jruby (master) 0.000000 0.000000 17.010000 ( 10.431316)
===========bench/strptime_Y-m-d_10000000.rb============
Rehearsal --------------------------------------------------
mri 2.4.1 0.000000 0.000000 11.100000 ( 11.600714)
jruby 9.1.9.0 0.000000 0.000000 509.540000 (564.931729)
jruby (master) 0.000000 0.000000 71.700000 ( 80.120338)
--------------------------------------- total: 592.340000sec
user system total real
mri 2.4.1 0.000000 0.000000 12.750000 ( 15.315754)
jruby 9.1.9.0 0.000000 0.000000 525.980000 (586.105106)
jruby (master) 0.000000 0.000000 66.050000 ( 65.739327)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment