1 Exception utilities
2 Number utilities
3 String utilities
4 Symbol utilities
5 SRFI19 time utilities
6 List
7 PLT 4x hash utilities
8 PLT 3x hash utilities
9 Contract utilities
10 File and path utilities
11 Parameter utilities
12 Syntax utilities
13 Generators
14 Generators (short names)
15 Pipelines
16 Write-through cache
17 Yieldable procedures
18 Debugging tools
19 Profiling tools
20 Logging tools
On this page:
timer
profile
with-timer
timer-value
current-timer
all-timers
define-timer
Version: 3.99.0.23

 

19 Profiling tools

 (require (planet untyped/unlib/profile))

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.

(with-timer timer expr ...)

Syntactic shorthand for:

  (profile timer (lambda () expr ...))

(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.

(current-timer)  timer?

Returns the timer that is currently running.

(all-timers)  (listof timer?)

Returns a list of all timers created with make-timer or define-timer, plus a single predefined timer called 'top.

(define-timer id)

Syntactic shorthand for:

  (define id (make-timer 'id))