summaryrefslogtreecommitdiff
path: root/simulation.scm
diff options
context:
space:
mode:
authorEkaitz Zarraga <ekaitz@elenq.tech>2024-12-28 20:28:47 +0100
committerEkaitz Zarraga <ekaitz@elenq.tech>2024-12-28 20:28:53 +0100
commitca5cb8b2b1f976705aa2a5e4b1086aecee1d395c (patch)
tree1878e50fcc98c996ec2c304a5b382d28876a4307 /simulation.scm
parentfdb2f7362f2de2c173c6c1f80910c11739178ab8 (diff)
simulation: logger time in millis and start at 0
Diffstat (limited to 'simulation.scm')
-rw-r--r--simulation.scm17
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))