Add basic pure benchmarks#110
Conversation
|
I'll put these in the changelog rather than the old school benchmarks. |
|
@idontgetoutmuch wrote:
Fantastic! I've backported the benchmarks in their current state to Those results are valid to compare to the ones posted here - same machine, same benchmarking code, etc. I had to benchmark with |
|
I didn't say it in the description originally, but I just want to make it clear that the times in the description are for 1048576 iterations in each case. I just stole that number from @lehins' benchmarks. I'm thinking of changing it to 1000000 just to make it a little easier to deduce the single iteration runtime. Edit: changed to 1000000. |
|
@curiousleo to it took |
|
@lehins ah cool, thanks for the explanation.
It is now :) Good point though. I've actually reduces the number of iterations further from 1_000_000 to 100_000 in a follow-up PR so we can easily compare It's not easy to communicate what these numbers mean. For Anyway, I'm just thinking aloud here. Thanks for your explanation. |
|
I was about to put the new benchmarks in the CHANGELOG but we have regressions There really should not be a regression though? |
#103 fixes |
Mostly stolen from https://github.com/lehins/haskell-benchmarks/tree/new-random/new-random-benchmarks.
Current results
All measurements here are for 1048576 iterations. I changed the number of iterations to 1000000 in a later commit for convenience, but the difference is within the margin of error in most cases, so I didn't update the times listed here in the description.
Optimisation
Note that
Charis an outlier. It uses rejection sampling under the hood because not everyWord32is a validChar. However, changing the method used fromunsignedBitmaskWithRejectionMtounbiasedWordMult32(as done in the second commit of this PR) approximately halves the time required to generate aChar:Before
$ stack bench random:bench --ba 'pure/uniform/Char' [...] benchmarked pure/uniform/Char time 11.56 ms (11.49 ms .. 11.62 ms) 1.000 R² (1.000 R² .. 1.000 R²) mean 11.44 ms (11.39 ms .. 11.47 ms) std dev 111.0 μs (74.00 μs .. 177.8 μs)After
$ stack bench random:bench --ba 'pure/uniform/Char' [...] benchmarked pure/uniform/Char time 6.238 ms (6.205 ms .. 6.275 ms) 1.000 R² (1.000 R² .. 1.000 R²) mean 6.457 ms (6.424 ms .. 6.494 ms) std dev 105.3 μs (90.97 μs .. 123.8 μs)