Skip to content

Conversation

lehins
Copy link
Contributor

@lehins lehins commented Dec 22, 2024

Naive implementation using sorting lists is too slow. Here we add basic support of mutable boxed arrays and use it to implement Fisher-Yates shuffle algorithm that proves to be at least x20 more efficient

  shuffle
    uniformShuffleList:  OK (0.72s)
      5.43 ms ± 155 μs
    uniformShuffleListM: OK (0.21s)
      14.2 ms ± 818 μs
    naiveShuffleListM:   OK (0.92s)
      313  ms ± 5.7 ms

I thought about my implementation from #140 really hard and I could not release such naive implementation with a clear conscience. 🙂

Resolves #158

Naive implementation using sorting lists is too slow. Here we add basic
support of mutable boxed arrays and use it to implement Fisher-Yates shuffle
algorithm that proves to be at least x20 more efficient

```
  shuffle
    uniformShuffleList:  OK (0.72s)
      5.43 ms ± 155 μs
    uniformShuffleListM: OK (0.21s)
      14.2 ms ± 818 μs
    naiveShuffleListM:   OK (0.92s)
      313  ms ± 5.7 ms
```
@lehins lehins force-pushed the lehins/use-array-for-shuffle branch from 5acf53d to a79f427 Compare December 25, 2024 22:41
@lehins lehins merged commit fb9dcb1 into master Dec 26, 2024
52 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.

Rewrite shuffleListM using array

1 participant