Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/juhp/prime-bench
https://github.com/juhp/prime-bench
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/juhp/prime-bench
- Owner: juhp
- License: bsd-3-clause
- Created: 2022-06-24T01:53:45.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-06-26T07:50:30.000Z (over 2 years ago)
- Last Synced: 2024-10-31T14:06:09.671Z (3 months ago)
- Language: Haskell
- Size: 11.7 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# prime-bench (wip)
tasty-bench of basic prime algorithms
So far it compares:
- naive isPrime over integers
- Bird's algorithm (taken from [Thinking Functionally with Haskell](https://www.cs.ox.ac.uk/publications/books/functional/))
- the circular algorithm from Colin Runciman's [Function Pearl](https://www.semanticscholar.org/paper/Lazy-Wheel-Sieves-and-Spirals-of-Primes-Runciman/09d512179ed4208604f6d8ddcb1c5f87217ebbe0)
- the [primes](https://hackage.haskell.org/package/primes) library which uses a wheel sieve, also based on the same paperThe benchmarking and `isPrime` are derived from the code in chapter 10 of [Haskell in Depth](https://github.com/bravit/hid-examples/blob/master/benchmarks/primcheck.hs) by Vitaly Bragilevsky.
## Output
```
isPrime 999999937
naive: OK (0.31s)
584 μs ± 51 μs
Bird: OK (0.27s)
62.1 μs ± 4.2 μs
circular: OK (1.04s)
62.0 μs ± 839 ns
primes: OK (0.25s)
61.8 μs ± 3.2 μs
primes isPrime: OK (0.13s)
61.3 μs ± 6.1 μs
prime 100000
Bird: OK (0.80s)
157 μs ± 14 μs
circular: OK (2.38s)
501 μs ± 29 μs
primes: OK (0.25s)
2.36 ms ± 193 μs
```## Build
Run with `cabal run` or `stack run`
## Contribute
Feedback and suggestions welcome