One Quickie


Timing stuff (DTrace->General)
To time stuff in DTrace, get the timestamp (wall-clock time) or vtimestamp (on-CPU time) in the entry. In the return, make sure you have a starting timestamp recorded (this avoids race conditions if the script is run if the function is currently in-flight). Then calculate the delta and do something with it (print it, aggregate it, whateva).
some:probe:description:entry
{
    self->start = timestamp;
}

some:probe:description:return
/self->start != 0/
{
    this->delta = timestamp - self->start;
    trace (this->delta);
    self->start = 0;
}



borkware home | products | miniblog | rants | quickies | cocoaheads
Advanced Mac OS X Programming book

webmonster@borkware.com