23 Profiling tools
Simple profiling tools.
(struct timer (name)) |
name : symbol? |
Structure used to record a running total time. Only one timer can be running at a time per thread. The accumulated time associated with a timer can be retrieved using timer-value and printed by printing the timer.
(profile timer fn arg ...) → any |
timer : timer? |
fn : procedure? |
arg : any |
Applies fn to args and returns the result. Measures the time taken to apply fn and adds it to the running total in timer. Timers are only updated when control passes into or out of a profile form.
Examples: |
> (define t1 (make-timer 't1)) |
> (profile t1 foldl + 0 (iota 1000000)) |
499999500000 |
> t1 |
#<timer:t1 0m 0.280s> |
(timer-value timer) → number? |
timer : timer? |
Returns the current value of timer. Timers are only updated when control passes into or out of a profile form.
(timer-reset! timer) → void? |
timer : timer? |
Resets timer to zero.
Returns a list of all timers created with make-timer or define-timer, plus a single predefined timer called 'top.