idontgetoutmuch / random

Random number library
Other
3 stars 2 forks source link

Reduce CPP use #156

Closed curiousleo closed 4 years ago

curiousleo commented 4 years ago

Context: https://github.com/haskell/random/pull/62/#discussion_r436206252.

Before (f78c2d8c781c2055d3c7a37293bbda280b6d305e):

pure/uniform/Word32                      mean 27.81 μs  ( +- 2.483 μs  )
pure/uniform/Word64                      mean 26.97 μs  ( +- 609.2 ns  )
pure/uniform/Word                        mean 27.03 μs  ( +- 729.5 ns  )

pure/uniform/Int32                       mean 27.32 μs  ( +- 1.476 μs  )
pure/uniform/Int64                       mean 28.19 μs  ( +- 6.877 μs  )
pure/uniform/Int                         mean 26.80 μs  ( +- 733.3 ns  )

After:

pure/uniform/Word32                      mean 26.91 μs  ( +- 737.7 ns  )
pure/uniform/Word64                      mean 27.23 μs  ( +- 990.5 ns  )
pure/uniform/Word                        mean 27.75 μs  ( +- 2.630 μs  )

pure/uniform/Int32                       mean 27.09 μs  ( +- 735.9 ns  )
pure/uniform/Int64                       mean 27.15 μs  ( +- 1.068 μs  )
pure/uniform/Int                         mean 26.94 μs  ( +- 839.0 ns  )
lehins commented 4 years ago

I just confirmed on a simple example runStateGen_ (mkStdGen 2020) uniformM :: Int witth ghc 7.10 and 8.8 the version with CPP and without CPP produce exactly the same core. So I am sure benchmark results will stay the same as well.

lehins commented 4 years ago

@idontgetoutmuch I don't think GHC can function without Machdeps.h :stuck_out_tongue_winking_eye: