tasty-bench-fit

Determine time complexity of a given function

https://github.com/Bodigrim/tasty-bench-fit

Version on this page:0.1@rev:3
LTS Haskell 22.41:0.1@rev:3
Stackage Nightly 2024-11-12:0.1.1
Latest on Hackage:0.1.1

See all snapshots tasty-bench-fit appears in

MIT licensed by Bodigrim
Maintained by [email protected]
This version can be pinned in stack with:tasty-bench-fit-0.1@sha256:7577c597abad1ab33e5ae18ec978d4b4cfa34d6f3c87b5640f9701d46f34edc7,1788

Module documentation for 0.1

tasty-bench-fit

Benchmark a given function for variable input sizes and find out its time complexity.

> fit $ mkFitConfig (\x -> sum [1..x]) (10, 10000)
1.2153e-8 * x
> fit $ mkFitConfig (\x -> Data.List.nub [1..x]) (10, 10000)
2.8369e-9 * x ^ 2
> fit $ mkFitConfig (\x -> Data.List.sort $ take (fromIntegral x) $ iterate (\n -> n * 6364136223846793005 + 1) (1 :: Int)) (10, 100000)
5.2990e-8 * x * log x

One can usually get reliable results for functions, which do not allocate much: like in-place vector sort or fused list operations like sum [1..x].

Unfortunately, fitting functions, which allocate a lot, is likely to be disappointing: GC kicks in irregularly depending on nursery and heap sizes and often skews observations beyond any recognition. Consider running such measurements with -O0 or in ghci prompt. This is how the usage example above was generated. Without optimizations your program allocates much more and triggers GC regularly, somewhat evening out its effect.

Changes

0.1

  • Initial release.