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

Faster minmax by using fold #968

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Philippe-Cholet
Copy link
Member

No description provided.

Do less comparisons by considering pairs is smart but this was done by `loop { it.next(), it.next() }` while `it.fold` is generally faster.
This results in a lot of changes but most of it is merely moving code and indentation corrections.
@Philippe-Cholet Philippe-Cholet added this to the next milestone Jul 6, 2024
Copy link

codecov bot commented Jul 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.67%. Comparing base (6814180) to head (f798d5a).
Report is 111 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #968      +/-   ##
==========================================
+ Coverage   94.38%   94.67%   +0.28%     
==========================================
  Files          48       49       +1     
  Lines        6665     7232     +567     
==========================================
+ Hits         6291     6847     +556     
- Misses        374      385      +11     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@phimuemue phimuemue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I think I get the idea. fold pairwise and see if there's one excess element that has to be processed manually.

Do you have some numbers that show that the proposed implementation indeed is faster? (My gut thought: For a slide, the existing implementation can just call next twice, whereas your proposal has to match acc twice, even though that seems unneeded.)

I'll approve this so that you can merge if you want. But I'd be happy about benchmarks that substantiate that we're taking the right direction.

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.

2 participants