8.16
Futures Visualizer
Parallelism with Futures in The Racket Guide introduces
(requirefuture-visualizer) | package:future-visualizer |
The futures visualizer is a graphical profiling tool for parallel programs written using future. The tool shows a timeline of a program’s execution including all future-related events, as well as the overall amount of processor utilization at any point during the program’s lifetime.
syntax
(visualize-futures e ...)
procedure
(visualize-futures-thunk thunk) → any
thunk : (-> any)
The visualize-futures macro enables the collection of data required by the visualizer and displays a profiler window showing the corresponding trace. The visualize-futures-thunk provides similar functionality where program code is contained within thunk.
A typical program using profiling might look like the following:
(require racket/future future-visualizer) (visualize-futures (let ([f (future (lambda () ...))]) ... (touch f)))
The preceding program is equivalent to:
(require racket/future future-visualizer/trace future-visualizer) (start-future-tracing!) (let ([f (future (lambda () ...))]) ... (touch f)) (stop-future-tracing!) (show-visualizer)
procedure
(show-visualizer #:timeline timeline) → void?
timeline : (listof indexed-future-event?)
Displays the visualizer window. If the function is called with no arguments, it must be preceded by the following sequence: a call to start-future-tracing!, program code that is being traced, and a call to stop-future-tracing! – in which case the visualizer will show data for all events logged in between those calls (via timeline-events). Note that visualize-futures and visualize-futures-thunk are simpler alternatives to using these primitives directly. The timeline argument can be used to show the visualizer for a previously-generated trace.