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

feat: faster splitAt #919

Merged
merged 1 commit into from
Aug 16, 2024
Merged

feat: faster splitAt #919

merged 1 commit into from
Aug 16, 2024

Conversation

kim-em
Copy link
Collaborator

@kim-em kim-em commented Aug 16, 2024

It turns out using List is faster than Array in the auxiliary functions for splitAt and splitAtD. It's about a 10% improvement (and much more for splitAtD when there is lots of padding).

I was a little surprised at first, so double checked my timings from #time #eval ... with a hyperfine "lean --run ..." benchmark.

@digama0
Copy link
Member

digama0 commented Aug 16, 2024

This is not actually that surprising, but I appreciate you getting hard numbers on this, I'd been hoping someone could verify this one way or another. The reason the list version performs competitively is because List.reverse works in-place, so it's not really wasting any allocations not involved in the final output. The array version is more compact but the array allocation is additional to the output.

@digama0 digama0 merged commit a36e34f into main Aug 16, 2024
3 checks passed
digama0 added a commit that referenced this pull request Aug 16, 2024
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