square / ruby-rrule

RRULE expansion for Ruby
Apache License 2.0
171 stars 25 forks source link

Improve performance of `between` method #11

Closed tcannonfodder closed 6 years ago

tcannonfodder commented 6 years ago

Allow a floor_date to be passed to RRule#each, for performance


Below are 2 runs of scripts/benchmark.rb, the first is this PR, the second is the current version (0.3.0)

$ git log -1 --pretty=oneline
a678a782070168fd2090b69968153d9a027bcd2e Allow a floor_date to be passed to `RRule#each`, for performance
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 12:01:00
$ ruby scripts/benchmark.rb
Benchmarking rules in version 0.3.0: 1000 expansions over one month
                           user     system      total        real
FREQ=WEEKLY            0.270000   0.010000   0.280000 (  0.277578)
FREQ=WEEKLY;BYDAY=WE   0.430000   0.000000   0.430000 (  0.429060)

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 12:01:10
$ git checkout 19e3e8d67dcf4810bbe65c20c851b50fbe0bce35
$ git log -1 --pretty=oneline
19e3e8d67dcf4810bbe65c20c851b50fbe0bce35 Merge pull request #9 from square/rmitchell/bump-version
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 12:01:30
$ ruby scripts/benchmark.rb
Benchmarking rules in version 0.3.0: 1000 expansions over one month
                           user     system      total        real
FREQ=WEEKLY            7.150000   0.040000   7.190000 (  7.210978)
FREQ=WEEKLY;BYDAY=WE  12.440000   0.080000  12.520000 ( 12.564897)
leecunliffe commented 6 years ago

This is fantastic, thanks so much @tcannonfodder!