Measure allocations of a Haskell functions/values


Version on this page:0.0.16
LTS Haskell 19.19:0.0.16@rev:1
Stackage Nightly 2022-08-17:0.0.16@rev:1
Latest on Hackage:0.0.16@rev:1

See all snapshots weigh appears in

BSD-3-Clause licensed by Chris Done
This version can be pinned in stack with:weigh-0.0.16@sha256:da118318d2211b325e7d6cd3729810729eb8f275e938e7113d0a4d3c51cdec29,1155

Module documentation for 0.0.16

Used by 1 package in lts-16.11(full list with versions):

weigh Build Status

Measures the memory usage of a Haskell value or function


  • :warning: Turn off the -threaded flag, otherwise it will cause inconsistent results.

Example use

import Weigh

main :: IO ()
main =
    (do func "integers count 0" count 0
        func "integers count 1" count 1
        func "integers count 10" count 10
        func "integers count 100" count 100)
    count :: Integer -> ()
    count 0 = ()
    count a = count (a - 1)

Output results:

Case Allocated GCs
integers count 0 16 0
integers count 1 88 0
integers count 10 736 0
integers count 100 7,216 0

Output by default is plain text table; pass --markdown to get a markdown output like the above.