[Haskell-cafe] Performance counters

minh thu noteed at gmail.com
Tue May 5 17:25:37 EDT 2009


2009/5/5 Andrew Coppin <andrewcoppin at btinternet.com>:
> Magnus Therning wrote:
>>
>> Andrew Coppin wrote:
>>>
>>> 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...)
>
> [I'm getting *really* tired of my ISP thinking that 30% of the traffic from
> Haskell-cafe is spam. If only there was a way to whitelist it or
> something... repeatedly clicking "this is not spam" doesn't seem to get the
> message across.]
>
> Um... hmm, that's a good question. Basically I've written a program that
> does adaptive sampling, and I want to see how much it's recursing. There are
> two parameters you can adjust: the minimum step size, and the maximum error
> tollerance. I'd like to know which of the two limits the program is
> reaching. (In other words, does the error eventually fall below the
> threshold, or does the step size become too small first?)
>
> I guess *ideally* I'd like the end user to be able to find this out from the
> running program... but I guess to do that there really is no other way than
> to sprinkle monads or unsafe I/O around the place.

Hi,

Since your recursive function has to test if the recursion should be
ended or continued,
when it ends, you know the reason. So why not just wrap your result
inside something like:

data Result a = ThresholdReached a | StepSizeTooSmall a

?

Also, passing an accumulator to the function to record the number of
steps should be
straightforward.

Cheers,
Thu


More information about the Haskell-Cafe mailing list