The weigh package

[ Tags: bsd3, library, web ] [ Propose Tags ]

Please see README.md


[Skip to Readme]

Properties

Versions 0.0.0, 0.0.1, 0.0.2, 0.0.3, 0.0.4, 0.0.5
Change log CHANGELOG
Dependencies base (>=4.7 && <5), deepseq, mtl, process, split, template-haskell, temporary [details]
License BSD3
Copyright FP Complete
Author Chris Done
Maintainer chrisdone@fpcomplete.com
Category Web
Home page https://github.com/fpco/weigh#readme
Uploaded Wed Aug 2 09:18:30 UTC 2017 by ChrisDone
Distributions LTSHaskell:0.0.5, NixOS:0.0.5, Stackage:0.0.5, Tumbleweed:0.0.4
Downloads 576 total (102 in the last 30 days)
Rating 0.0 (0 ratings) [clear rating]
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2017-08-02 [all 1 reports]
Hackage Matrix CI

Modules

[Index]

Flags

NameDescriptionDefaultType
weigh-maps

Weigh maps.

DisabledManual

Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info

Downloads

Maintainer's Corner

For package maintainers and hackage trustees


Readme for weigh-0.0.5

[back to package description]

weigh Build Status

Measures the memory usage of a Haskell value or function

Example use

import Weigh

-- | Weigh integers.
main :: IO ()
main =
  mainWith (do integers
               ints)

-- | Just counting integers.
integers :: Weigh ()
integers =
  do func "integers count 0" count 0
     func "integers count 1" count 1
     func "integers count 2" count 2
     func "integers count 3" count 3
     func "integers count 10" count 10
     func "integers count 100" count 100
  where count :: Integer -> ()
        count 0 = ()
        count a = count (a - 1)

-- | We count ints and ensure that the allocations are optimized away
-- to only two 64-bit Ints (16 bytes).
ints :: Weigh ()
ints =
  do validateFunc "ints count 1" count 1 (maxAllocs 24)
     validateFunc "ints count 10" count 10 (maxAllocs 24)
     validateFunc "ints count 1000000" count 1000000 (maxAllocs 24)
  where count :: Int -> ()
        count 0 = ()
        count a = count (a - 1)

Output results:

Case                Bytes  GCs  Check
integers count 0        0    0  OK
integers count 1       32    0  OK
integers count 2       64    0  OK
integers count 3       96    0  OK
integers count 10     320    0  OK
integers count 100  3,200    0  OK
ints count 1            0    0  OK
ints count 10           0    0  OK
ints count 1000000      0    0  OK

You can try this out with stack test in the weight directory.

To try out other examples, try:

  • stack test :weigh-maps --flag weigh:weigh-maps