To time stuff in DTrace, get the timestamp (wall-clock time) or vtimestamp (on-CPU time) in theentry
. In thereturn
, 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; }