timev
timev-apply
timev
*timev?*
8.12

timev🔗ℹ

Laurent Orseau

 (require timev) package: levintreesearch_cm

timev is a more flexible variant of time.

procedure

(timev-apply label [#:disp? disp?] proc arg ...)  any

  label : string?
  disp? : any/c = (*timev?*)
  proc : procedure?
  arg : any/c
Similar to time but prefixes the displayed time string with label.

If disp? is #f, no timing information is displayed.

Nested calls to timev-apply are indented to reflect the nesting.

syntax

(timev label [#:disp? (*timev?*)] body ...)

A more practical form of timev-apply.

Example:
> (timev "Level 0"
         (timev "Level 1a"
                (timev "Level 2"
                       (displayln "Some user output from level 2")))
         (timev "Level 1b"
                (displayln "Some user output from level 1"))
         (displayln "Some user output from level 0"))

Some user output from level 2

  Level 2 cpu: 0 real: 0 gc: 0

 Level 1a cpu: 0 real: 0 gc: 0

Some user output from level 1

 Level 1b cpu: 0 real: 0 gc: 0

Some user output from level 0

Level 0 cpu: 0 real: 0 gc: 0

procedure

(*timev?*)  boolean?

 = #t
A global to make it easy to turn on/off timev information with a switch from the command line.

For example:
#lang racket
(require timev global)
 
(*timev?* #f) ; turn timev display off by default
 
;; Use the --timev switch from the command line
;; to display timev information
(void (globals->command-line)) ; parse the command line
 
(timev "Calculation time: "
       (+ 1 2))
 
(timev "Never print me" #:disp? #f
       (+ 1 2))