Bodigrim / tasty-bench

Featherlight benchmark framework, drop-in replacement for criterion and gauge.
https://hackage.haskell.org/package/tasty-bench
MIT License
80 stars 11 forks source link

Think about benchmarking of linear and unlifted data #34

Closed Bodigrim closed 1 year ago

Bodigrim commented 2 years ago

For benchmarking of linear functions there are two options. One approach is to make nf and friends multiplicity-polymorphic. This does not require any implementation changes, just tweaking of type signatures and CPP around it. Not convinced that it's worth it. The second options is more a workaround: if you have a linear function f, which you wish to benchmark, you can benchmark \x -> f x instead, which is no longer linear and thus does not need any special support. I'm currently leaning to say that the second option is good enough. Cf. https://github.com/haskell/criterion/pull/263

More interesting is how to benchmark functions, whose inputs and outputs are not in Type. I can very well imagine someone wishing to use Int# as an input and an unlifted type as an output, so that no time is wasted for pointer chasing and tag checking. While this is doable for every specific RuntimeRep, I have not found an ergonomic way to be levity-polymorphic here. And type signature grows to be quite scary.

Bodigrim commented 1 year ago

Closing: