12345678910111213141516171819202122232425262728 |
- (library (timing)
- (export time)
- (import
- (except (rnrs base)
- let-values
- map
- error
- vector-map)
- (only (guile)
- lambda* λ
- simple-format)
- ;; format
- (ice-9 format)
- ;; time stuff
- (srfi srfi-19))
- (define-syntax time
- (syntax-rules ()
- [(time expr expr* ...)
- (let ([start-time (current-time time-monotonic)])
- (let ([result (begin expr expr* ...)])
- (let ([end-time (current-time time-monotonic)])
- (let* ([diff (time-difference end-time start-time)]
- [elapsed-ns (+ (/ (time-nanosecond diff) 1e9)
- (time-second diff))])
- (simple-format #t "~a\n" (format #f "~fs~%" elapsed-ns)))
- result)))])))
|