diff options
author | Ekaitz Zarraga <ekaitz@elenq.tech> | 2024-12-28 20:28:47 +0100 |
---|---|---|
committer | Ekaitz Zarraga <ekaitz@elenq.tech> | 2024-12-28 20:28:53 +0100 |
commit | ca5cb8b2b1f976705aa2a5e4b1086aecee1d395c (patch) | |
tree | 1878e50fcc98c996ec2c304a5b382d28876a4307 | |
parent | fdb2f7362f2de2c173c6c1f80910c11739178ab8 (diff) |
simulation: logger time in millis and start at 0
-rw-r--r-- | simulation.scm | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/simulation.scm b/simulation.scm index 6728c42..938500d 100644 --- a/simulation.scm +++ b/simulation.scm @@ -48,13 +48,18 @@ (let ((msg (get-message *output-channel*))) (display msg)))) +(define (time->milliseconds time) + (let* ((seconds (car time)) + (micros (cdr time))) + (+ (* 1000 seconds) (round (/ micros 1000))))) +(define %start-time (time->milliseconds (gettimeofday))) (define (ll f . data) - (let ((now (gettimeofday))) - (spawn-fiber - (lambda () - (put-message - *output-channel* - (format #f "~d~6'0d - ~?~%" (car now) (cdr now) f data)))))) + (spawn-fiber + (lambda () + (put-message + *output-channel* + (format #f "~12'0d - ~?~%" (- (time->milliseconds (gettimeofday)) + %start-time) f data))))) ;; Synchronized id generator (define *id-channel-in* (make-channel)) |