Gabriella439 / pipes

Compositional pipelines
BSD 3-Clause "New" or "Revised" License
487 stars 72 forks source link

optimize take and drop #154

Closed michaelt closed 8 years ago

michaelt commented 8 years ago

This is not important but for some reason, the use of the imported replicateM_ for take and drop impedes optimization. I noticed this fiddling with some machines benchmarks of individual functions. See https://gist.github.com/michaelt/f19bef01423b17f29ffd The first list of results is hackage-pipes; the second is with these two repairs

benchmarking drop/conduit
 time                 26.56 ms   (26.31 ms .. 26.79 ms)
benchmarking drop/pipes
 time                 43.64 ms   (42.48 ms .. 45.46 ms)

-- and with the modified drop:

benchmarking drop/pipes
time                 28.03 ms   (26.75 ms .. 29.67 ms)

Then

benchmarking take/conduit
time                 45.38 ms   (44.57 ms .. 46.45 ms)
benchmarking take/pipes
time                 84.44 ms   (78.23 ms .. 91.36 ms)

and with the modified take:

benchmarking take/pipes
time                 55.05 ms   (53.84 ms .. 56.26 ms)
Gabriella439 commented 8 years ago

Thank you! I'm wonder why replicateM_ incurs such a performance hit