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

Add dumb loop microbenchmark #349

Merged
merged 2 commits into from
Dec 3, 2024
Merged

Add dumb loop microbenchmark #349

merged 2 commits into from
Dec 3, 2024

Conversation

maximecb
Copy link
Contributor

@maximecb maximecb commented Dec 3, 2024

This is a modified version of a microbenchmark circulated on twitter by "TheDumbTechGuy". It's obviously not representative of most Ruby code, but it does show areas where we could perform much better with better inlining and better quality code generation.

This is a modified version of a microbenchmark circulated on
twitter by "TheDumbTechGuy". It's obviously not representative of
most Ruby code, but it does show areas where we could perform
much better with better inlining and better quality code
generation.
@maximecb maximecb enabled auto-merge (squash) December 3, 2024 21:10
@maximecb maximecb merged commit 1dbbdce into main Dec 3, 2024
4 checks passed
@maximecb maximecb deleted the loop_bench branch December 3, 2024 21:20

4_000.times do |i|
4_000.times do |j|
a[i] += j % u
Copy link
Contributor

@eregon eregon Dec 4, 2024

Choose a reason for hiding this comment

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

This modulo in the inner loop likely dominates the benchmark, I'd suggest to use & 0b111 or so instead.

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.

3 participants