Skip to content

Commit

Permalink
Show timing for commands
Browse files Browse the repository at this point in the history
  • Loading branch information
greghendershott committed Apr 28, 2023
1 parent 141023a commit dcb3a86
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions racket/command-server.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,18 @@
(define response-channel (make-channel))

(define (do-command/queue-response nonce sid sexp)
;; Make "label" for logging. A thread name comes from its thunk ∴
;; renaming the thunk lets us log the thread more informatively.
(define label (command-invocation-label nonce sid sexp))
(define (thk)
(channel-put
response-channel
(cons
nonce
(with-handlers ([exn:fail? (λ (e) `(error ,(exn-message e)))]
[exn:break? (λ (e) `(break))])
`(ok ,(call-with-session-context sid command sexp))))))
;; Make "label" for logging. A thread name comes from its thunk ∴
;; renaming the thunk lets us log the thread more informatively.
(define label (command-invocation-label nonce sid sexp))
(log-racket-mode-info label)
(with-time/log label
`(ok ,(call-with-session-context sid command sexp)))))))
(procedure-rename thk (string->symbol label)))

(define (write-responses-forever)
Expand Down
2 changes: 1 addition & 1 deletion racket/util.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
(define (time-apply/log what proc args)
(define-values (vs cpu real gc) (time-apply proc args))
(define (fmt n) (~v #:align 'right #:min-width 4 n))
(log-racket-mode-debug "~a cpu | ~a real | ~a gc <= ~a"
(log-racket-mode-debug "~a cpu | ~a real | ~a gc :: ~a"
(fmt cpu) (fmt real) (fmt gc) what)
(apply values vs))

Expand Down

0 comments on commit dcb3a86

Please sign in to comment.