updated slice.ptr_rotate() to include a small rotation with buffer - #7101
Open
TheRadischen wants to merge 5 commits into
Open
updated slice.ptr_rotate() to include a small rotation with buffer#7101TheRadischen wants to merge 5 commits into
TheRadischen wants to merge 5 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Change
Added a stack rotate for small rotations,
Buffer is set to [256]byte by default, but bigger would be better
Gries-Mill automatically exits when the rest fits in 256 bytes
Motivation
test: https://github.com/TheRadischen/odin-utils/tree/main/rotate
Benchmarks
average, type: int, many different rotation length
size: 10 iter: 10000 slice.rotate: 3┬Ás small_rotate: 1.1┬Ás diff: 2.727272727272727size: 100 iter: 1000 slice.rotate: 12.2┬Ás small_rotate: 5.5┬Ás diff: 2.2181818181818183size: 1000 iter: 100 slice.rotate: 52┬Ás small_rotate: 48.9┬Ás diff: 1.0633946830265848size: 10000 iter: 10 slice.rotate: 489.4┬Ás small_rotate: 491.6┬Ás diff: 0.9955248169243287size: 100000 iter: 5 slice.rotate: 4.9433ms small_rotate: 4.964ms diff: 0.9958299758259468size: 1000000 iter: 5 slice.rotate: 105.5177ms small_rotate: 106.5284ms diff: 0.9905123891844804worse case: type: int, small left rotation (0 to 32)
size: 10 iter: 100000 slice.rotate: 900ns small_rotate: 300ns diff: 3size: 100 iter: 10000 slice.rotate: 3.7┬Ás small_rotate: 700ns diff: 5.285714285714286size: 1000 iter: 1000 slice.rotate: 31.7┬Ás small_rotate: 2.4┬Ás diff: 13.208333333333334size: 10000 iter: 100 slice.rotate: 309.3┬Ás small_rotate: 30.4┬Ás diff: 10.174342105263158size: 100000 iter: 10 slice.rotate: 3.2229ms small_rotate: 362.1┬Ás diff: 8.900579950289975size: 1000000 iter: 5 slice.rotate: 43.7188ms small_rotate: 22.3035ms diff: 1.9601766538884031worste case: type: u8, small left rotation (0 to 100)
size: 10 iter: 10000 slice.rotate: 3.3┬Ás small_rotate: 1┬Ás diff: 3.3size: 100 iter: 1000 slice.rotate: 12.5┬Ás small_rotate: 1.4┬Ás diff: 8.928571428571429size: 1000 iter: 100 slice.rotate: 50.3┬Ás small_rotate: 2┬Ás diff: 25.15size: 10000 iter: 10 slice.rotate: 409.2┬Ás small_rotate: 8.8┬Ás diff: 46.5size: 100000 iter: 5 slice.rotate: 3.9645ms small_rotate: 123.6┬Ás diff: 32.0752427184466size: 1000000 iter: 5 slice.rotate: 40.0785ms small_rotate: 1.6411ms diff: 24.42172932788983