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

Prefer IO::Event::Timers. #316

Merged
merged 1 commit into from
Jun 3, 2024
Merged

Prefer IO::Event::Timers. #316

merged 1 commit into from
Jun 3, 2024

Conversation

ioquatix
Copy link
Member

@ioquatix ioquatix commented Jun 3, 2024

Minor performance improvement as demonstrated by attached benchmarks.

samuel@Sakura ~/D/s/a/b/timers (use-io-event-timers)> bundle exec ./after_0.rb 
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [arm64-darwin23]
Warming up --------------------------------------
       Timers::Group    65.144k i/100ms
   IO::Event::Timers   130.653k i/100ms
Calculating -------------------------------------
       Timers::Group    658.748k (± 0.5%) i/s -    716.584k in   1.087824s
   IO::Event::Timers      1.304M (± 0.2%) i/s -      1.307M in   1.002237s

Comparison:
   IO::Event::Timers:  1303616.9 i/s
       Timers::Group:   658747.8 i/s - 1.98x  slower

samuel@Sakura ~/D/s/a/b/timers (use-io-event-timers)> bundle exec ./after_n.rb
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [arm64-darwin23]
Warming up --------------------------------------
       Timers::Group    13.982k i/100ms
   IO::Event::Timers    21.496k i/100ms
Calculating -------------------------------------
       Timers::Group    154.925k (± 0.8%) i/s -    167.784k in   1.083072s
   IO::Event::Timers    230.674k (± 0.3%) i/s -    236.456k in   1.025078s

Comparison:
   IO::Event::Timers:   230673.5 i/s
       Timers::Group:   154925.4 i/s - 1.49x  slower

samuel@Sakura ~/D/s/a/b/timers (use-io-event-timers)> bundle exec ./after_cancel.rb
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [arm64-darwin23]
Warming up --------------------------------------
       Timers::Group   101.792k i/100ms
   IO::Event::Timers   232.860k i/100ms
Calculating -------------------------------------
       Timers::Group      1.006M (± 1.0%) i/s -      1.018M in   1.011619s
   IO::Event::Timers      2.544M (± 3.2%) i/s -      2.561M in   1.008093s

Comparison:
   IO::Event::Timers:  2543646.0 i/s
       Timers::Group:  1006322.4 i/s - 2.53x  slower

This was always on the cards, I just hadn't gotten around to it.

Types of Changes

  • Performance improvement.

Contribution

@ioquatix ioquatix merged commit a09253e into main Jun 3, 2024
44 of 48 checks passed
@ioquatix ioquatix deleted the use-io-event-timers branch June 3, 2024 12:55
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

Successfully merging this pull request may close these issues.

1 participant