Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Date and DateTime parsing slower than 1.7 and much slower than MRI #3640

Closed
mjc opened this issue Feb 3, 2016 · 3 comments
Closed

Date and DateTime parsing slower than 1.7 and much slower than MRI #3640

mjc opened this issue Feb 3, 2016 · 3 comments

Comments

@mjc
Copy link
Contributor

@mjc mjc commented Feb 3, 2016

string = "2016-02-03T17:44:04Z"

Benchmark.ips do |x|
  x.config warmup: 90 if RUBY_PLATFORM == 'java'
  x.report("Date#parse") { Date.parse(string) }
  x.report("DateTime#parse") { DateTime.parse(string) }
end

1.7.23:

          Date#parse     23.823k (± 4.3%) i/s -    119.444k
      DateTime#parse     17.959k (±10.8%) i/s -     89.750k

9.0.5.0:

          Date#parse     14.201k (±11.8%) i/s -     70.884k
      DateTime#parse     11.330k (±10.1%) i/s -     57.246k

MRI 2.3.0

          Date#parse     61.387k (± 4.6%) i/s -    308.966k
      DateTime#parse     60.220k (± 6.5%) i/s -    301.658k
@kares
Copy link
Member

@kares kares commented Jan 17, 2017

9K still doing noticeably worse than 1.7, invented a new benchmark script :

require 'benchmark'
require 'date'

string = "2016-02-03T17:44:04Z"

Benchmark.bmbm do |x|
  x.report("Date#parse") { 100_000.times{ Date.parse(string) } }
  x.report("DateTime#parse") { 100_000.times { DateTime.parse(string) } }
end

2.3.3

Rehearsal --------------------------------------------------
Date#parse       2.170000   0.000000   2.170000 (  2.173531)
DateTime#parse   2.230000   0.000000   2.230000 (  2.238035)
----------------------------------------- total: 4.400000sec

                     user     system      total        real
Date#parse       2.250000   0.000000   2.250000 (  2.244404)
DateTime#parse   2.300000   0.000000   2.300000 (  2.295370)

1.7.25

Rehearsal --------------------------------------------------
Date#parse      11.970000   0.040000  12.010000 (  6.722000)
DateTime#parse  12.220000   0.020000  12.240000 (  8.419000)
---------------------------------------- total: 24.250000sec

                     user     system      total        real
Date#parse       5.010000   0.010000   5.020000 (  4.920000)
DateTime#parse   7.040000   0.010000   7.050000 (  6.988000)

9.1.7.0

Rehearsal --------------------------------------------------
Date#parse      16.450000   0.120000  16.570000 ( 10.357322)
DateTime#parse  17.600000   0.050000  17.650000 ( 11.852176)
---------------------------------------- total: 34.220000sec

                     user     system      total        real
Date#parse      10.110000   0.020000  10.130000 (  9.630812)
DateTime#parse  10.350000   0.010000  10.360000 ( 10.310710)
@headius
Copy link
Member

@headius headius commented Mar 3, 2017

More work needed here than we have time for in 9.1.8.0, but I want to work on this for 9.2. I'll re-target.

Note that I had some patches in #1662 that seemed to help, and there's a bit of Java integration happening here that we don't optimize as well as we could (e.g. indy does not bind directly but still goes through reflection).

@kares
Copy link
Member

@kares kares commented Jun 26, 2017

believe work at #4635 (+ more commits already on master) resolves this to much acceptable numbers

@kares kares closed this Jun 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.