8000 50 times slower than Date.parse · Issue #430 · mojombo/chronic · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

50 times slower than Date.parse #430

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

Open
forthrin opened this issue Feb 2, 2025 · 0 comments
Open

50 times slower than Date.parse #430

forthrin opened this issue Feb 2, 2025 · 0 comments

Comments

@forthrin
Copy link
forthrin commented Feb 2, 2025

Needed to parse (Yesterday, Today, Tomorrow, Monday .. Sunday) relative to a given date.

Anyone knows how to:

  • Speed up this library to match Date.parse
  • Another library that can do this? (Except Rails)
$ time ruby -rtime -rchronic -rprofile -e "1000.times { Date.parse('Monday') }" 2>&1 | head
  %   cumulative   self              self     total
 time   seconds   seconds    calls  ms/call  ms/call  name
 51.74     0.02      0.02     1000     0.02     0.03  Date.parse
 15.81     0.03      0.01        1     5.99    36.49  Integer#times
  6.86     0.03      0.00     1000     0.00     0.03  nil#
  3.68     0.03      0.00     1000     0.00     0.00  Regexp#match
  2.90     0.03      0.00     1000     0.00     0.00  MatchData#begin
  2.45     0.03      0.00     1000     0.00     0.00  String#gsub!
  2.21     0.03      0.00     1000     0.00     0.00  MatchData#end
  2.07     0.03      0.00     1000     0.00     0.00  String#[]=
0m0.134s

$ time ruby -rtime -rchronic -rprofile -e "1000.times { Chronic.parse('Monday') }" 2>&1 | head
  %   cumulative   self              self     total
 time   seconds   seconds    calls  ms/call  ms/call  name
 19.92     1.25      1.25   131000     0.01     0.08  Chronic::Handler#match
 18.77     2.43      1.18   199000     0.01     0.01  Chronic::Handler#tags_match?
 10.97     3.12      0.69    64000     0.01     0.03  Chronic::Numerizer.numerize
  5.91     3.49      0.37    57000     0.01     0.18  Array#each
  5.37     3.83      0.34    49000     0.01     0.01  String#gsub
  5.16     4.15      0.32    61000     0.01     0.01  Chronic::Tag.scan_for
  2.96     4.34      0.19   306000     0.00     0.00  Array#[]
  2.12     4.47      0.13    50000     0.00     0.06  Array#each_index
0m7.419s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant
0