
Andrew Coppin wrote:
Don Stewart wrote:
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.
Stuff like "how many times does this function get called? How what's the maximum depth it recurses to?" That kind of thing.
It won't help you, but wouldn't it be the kind of thing that'd fit in the GHC runtime? Do you also require that the counters are available to the program itself? (This is starting to sound like something Don mentioned in his talk in London...) /M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus@therning.org Jabber: magnus@therning.org http://therning.org/magnus identi.ca|twitter: magthe