[PATCH] Add the stopwatch.stp tapset

William Cohen wcohen@redhat.com
Mon Jan 30 17:53:00 GMT 2012


On 01/26/2012 07:58 PM, Frank Ch. Eigler wrote:
> William Cohen <wcohen@redhat.com> writes:
> 
>> The stopwatch.stp tapset provides multiple, independent timers to user
>> scripts.  Stopwatches can be created by the user script at
>> anytime. [...]
> 
> Might you consider a somewhat simpler API?
> 
> function start_stopwatch (name:string) { }
> function stop_stopwatch (name:string) { }
> function read_stopwatch_ns:long (name:string) { }
> function read_stopwatch_us:long (name:string) { }
> function read_stopwatch_ms:long (name:string) { }
> function read_stopwatch_s:long (name:string) { }
> 
> i.e., no explicit create (the tapset can create it on first encounter
> of a new name), no enums (encode start/stop as distinct functions),
> and explicit reader functions.
> 
> - FChE


Hi Frank,

One thing missing from the simpler API is a way to clean things up.  If a script has many stopwatches of limited lifetime, it would be possible for the stopwatch tapset to cause the associative arrays to fill up.  There needs to be a:

function delete_stopwatch (name:string) {}

probably should have matching optional that can be explicitly called if desired:

function create_stopwatch (name:string) {}

Going through and trying to code up this API this afternoon.

-Will



More information about the Systemtap mailing list