Skip to content

Make .Clear faster by ~20% #36

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

Merged
merged 2 commits into from
Feb 13, 2025
Merged

Conversation

Andrew-Morozko
Copy link
Contributor

Using built-in clear() to zero-out contiguous array slices instead of zeroing elements one by one

name               old time/op    new time/op    delta
ClearContiguous-4     294µs ± 9%     237µs ±36%  -19.23%  (p=0.001 n=13+15)
ClearSplit-4          321µs ±11%     248µs ± 8%  -22.60%  (p=0.000 n=14+13)

name               old alloc/op   new alloc/op   delta
ClearContiguous-4     524kB ± 0%     524kB ± 0%   -0.00%  (p=0.000 n=11+12)
ClearSplit-4          524kB ± 0%     524kB ± 0%   -0.00%  (p=0.000 n=12+15)

name               old allocs/op  new allocs/op  delta
ClearContiguous-4      1.00 ± 0%      1.00 ± 0%     ~     (all equal)
ClearSplit-4           1.00 ± 0%      1.00 ± 0%     ~     (all equal)

Co-authored-by: Andrew Gillis <[email protected]>
@Andrew-Morozko
Copy link
Contributor Author

yep, overcomplicated that one, sorry)

@gammazero gammazero merged commit 6ef1959 into gammazero:main Feb 13, 2025
2 checks passed
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