in reply to OO lifetime function stats mod, is this useful?

The way you play with coderefs and for loops is vaguely reminiscent of map.. I'm not sure what I want to get at, since I don't have a deep CS theory background, but my intuition tells me you're doing something that could be generalized better in the functional programming paradigma.

Makeshifts last the longest.

  • Comment on Re: OO lifetime function stats mod, is this useful?

Replies are listed 'Best First'.
Re: Re: OO lifetime function stats mod, is this useful?
by shotgunefx (Parson) on Jun 28, 2002 at 15:22 UTC
    The for loops were just for example, it could easily be one function you want to track. The coderefs are needed because I'm basically trying to wrap a function call with args and track it over time (actually intervals. Not neccassarily the same thing.) The coderef provides a generic hook for performing an action. Now some functions might be builtins or return "0 but true" so the boolean is a generic way to let you defined the truth test. It is an optional argument.

    I could see several uses. You could use it to track and monitor the performance of a different aspects of a server (HTTP Requests,IO latency, memory usage, etc). Mainly what it's for.

    -Lee

    "To be civilized is to deny one's nature."
      Then I think what you really want to do is to provide a generic statskeeper hook to use with Hook::WrapSub, as that will allow one to directly call the initial function, rather than creating an object that wraps a coderef and then calling execute() on it.

      Makeshifts last the longest.

        Well it might not be a function per say. It might be a statement or a series of functions or a method which needs it's state bound in the closure. Here's a simple example server monitor script. Note the module isn't done. I banged it out in a few hours and a few accessors and such are missing.