haskell / statistics

A fast, high quality library for computing with statistics in Haskell.
http://hackage.haskell.org/package/statistics
BSD 2-Clause "Simplified" License
300 stars 68 forks source link

Should `mean` also have an INLINE pragma? #115

Closed fhaust closed 7 years ago

fhaust commented 7 years ago

I just wondered why mean doesn't have an INLINE pragma. I guess you are aware that this will prevent stream fusion, so I expect there to be another reason especially because there are INLINES on other functions?

Shimuuar commented 7 years ago

I don't really know. Commit which replaced INLINE with SPECIALIZE pragmas doesn't either. Maybe to avoid having multiple copies of mean etc in executable. Please reopen if it causes performance problems for you.

fhaust commented 7 years ago

I don't have any hard measurements, but from experience inlining calls to vector is faster in most cases. On the other hand the current mean implementation does two folds (ie traversals) which is slow in any case :-)