Search code examples
haskellwinghci

Haskell WinGHC Running Program with Performance Statistics


Using WinGHC how can i run my program with the +RTS -sstderr option to get statistics like compile time, memory useage or anything else of interest?

Currently i am using the command line: ghc -rtsopts -O3 -prof -auto-all Main.hs


Solution

  • Using WinGHCi set your active directory where your program is e.g.

     Prelude> :cd C:\Haskell
    

    Then, when you are in the right directory as per previous comments above enter:

    Prelude> :! ghc +RTS -s -RTS -O2 -prof -fprof-auto Main.hs
    

    The 'Main.hs' should be your program name.

    This will then give statistics as follows:

     152,495,848 bytes allocated in the heap
      36,973,728 bytes copied during GC
      10,458,664 bytes maximum residency (5 sample(s))
       1,213,516 bytes maximum slop
              21 MB total memory in use (0 MB lost due to fragmentation)
    
                                    Tot time (elapsed)  Avg pause  Max pause
     Gen  0       241 colls,     0 par    0.14s    0.20s     0.0008s    0.0202s
     Gen  1         5 colls,     0 par    0.08s    0.12s     0.0233s    0.0435s
     etc..........
     etc.............
    

    Other flags can be set to see other statistics.