|
|
|
@ -1,7 +1,8 @@
|
|
|
|
|
#lang racket/base
|
|
|
|
|
(require racket/string (for-syntax racket/base) "define.rkt")
|
|
|
|
|
|
|
|
|
|
(provide+safe report report/line report/file
|
|
|
|
|
(provide+safe report report/time time-name
|
|
|
|
|
report/line report/file
|
|
|
|
|
report* report*/line report*/file
|
|
|
|
|
report-apply repeat time-repeat time-repeat* compare)
|
|
|
|
|
|
|
|
|
@ -20,6 +21,17 @@
|
|
|
|
|
(apply values expr-results))]))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(define-syntax (report/time stx)
|
|
|
|
|
(syntax-case stx ()
|
|
|
|
|
[(MACRO EXPR) #'(MACRO EXPR EXPR)]
|
|
|
|
|
[(_ EXPR NAME)
|
|
|
|
|
#'(let* ([op (open-output-string)]
|
|
|
|
|
[expr-results (parameterize ([current-output-port op])
|
|
|
|
|
(time (call-with-values (λ () EXPR) list)))])
|
|
|
|
|
(eprintf "~a = ~a [~a]\n" 'NAME (stringify-results expr-results) (string-trim (get-output-string op)))
|
|
|
|
|
(apply values expr-results))]))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(define-syntax (report/line stx)
|
|
|
|
|
(syntax-case stx ()
|
|
|
|
|
[(MACRO EXPR) #'(MACRO EXPR EXPR)]
|
|
|
|
@ -78,6 +90,16 @@
|
|
|
|
|
(values (time-repeat n EXPR) ...))]))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(define-syntax (time-name stx)
|
|
|
|
|
(syntax-case stx ()
|
|
|
|
|
[(_ NAME EXPR ...)
|
|
|
|
|
#'(let* ([op (open-output-string)]
|
|
|
|
|
[expr-results (parameterize ([current-output-port op])
|
|
|
|
|
(time (call-with-values (λ () EXPR ...) values)))])
|
|
|
|
|
(display (format "~a: ~a" 'NAME (get-output-string op)))
|
|
|
|
|
expr-results)]))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(define-syntax (compare stx)
|
|
|
|
|
(syntax-case stx ()
|
|
|
|
|
[(_ EXPR ID ID-ALT ...)
|
|
|
|
|