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.
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 functionf
, 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/263More interesting is how to benchmark functions, whose inputs and outputs are not in
Type
. I can very well imagine someone wishing to useInt#
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 specificRuntimeRep
, I have not found an ergonomic way to be levity-polymorphic here. And type signature grows to be quite scary.