[Haskell-cafe] Performance counters

Don Stewart dons at galois.com
Mon May 4 16:28:13 EDT 2009


andrewcoppin:
> OK, so I'm pretty sure I'm not the first person to run into this...
>
> I've got a fairly large, complex program. It seems to work fine. But now  
> I want to add some counters to measure various things.
>
> Trouble is, to do that, I'd have to "infect" the entire program with  
> boilerplate code to propogate these counters. At best I could wrap it up  
> in a monad, but it's still annoying to have to make 90% of the code in  
> the program monadic just to carry these performance counters around.
>
> Does anybody know of a better solution? I could use the dreaded  
> unsafePerformIO to prod some IORefs, but now you have to start  
> sprinkling NOINLINE pragmas around and hope you know what you're  
> doing... Scary! o_O

What kind of counters? Do you just want to measure how often things are
evaluated? Use -fhpc (which inserts 'ticks' for you).

Otherwise, you'll need some kind of manual tick system.

-- Don


More information about the Haskell-Cafe mailing list