Fix internal-latency-syndicate.rkt

This commit is contained in:
Tony Garnock-Jones 2019-06-21 14:42:21 +01:00
parent 63146632fe
commit b3be7a8e83
1 changed files with 12 additions and 10 deletions

View File

@ -2,7 +2,7 @@
;; Measurement of message delivery latency.
(require racket/match)
(require prospect)
(require syndicate)
(require logbook)
(provide run)
@ -25,7 +25,10 @@
))
(define (pinger src dst)
(spawn (lambda (e s)
(actor #:assertions* (patch->initial-assertions
(patch-seq (sub (ping dst src ?))
(sub 'kickoff)))
(lambda (e s)
(match e
[(message 'kickoff)
(set! run-start-time (current-inexact-milliseconds))
@ -38,7 +41,7 @@
(define delta (- stop-time start-time))
(set! total-latency (+ total-latency delta))
(set! total-roundtrips (+ total-roundtrips 1))
(when (zero? (modulo total-roundtrips 1000))
(when (zero? (modulo total-roundtrips 10000))
(log-info "After ~a roundtrips, ~a milliseconds; ~a Hz"
total-roundtrips
total-latency
@ -49,19 +52,18 @@
'()))]
[_ #f]))
#f
(patch-seq (sub (ping dst src ?))
(sub 'kickoff)
(pub (ping src dst ?)))))
'()))
(define (echoer id)
(spawn (lambda (e s)
(actor #:assertions* (patch->initial-assertions
(sub (ping ? id ?)))
(lambda (e s)
(match e
[(message (ping src (== id) stamp))
(transition s (message (ping id src stamp)))]
[_ #f]))
#f
(patch-seq (sub (ping ? id ?))
(pub (ping id ? ?)))))
'()))
(begin
(run-ground (for/list [(id (in-range echoer-count))] (echoer id))
@ -71,7 +73,7 @@
(module+ main
(define t 10000)
(define E (standard-logbook-entry (default-logbook #:verbose? #t) "minimart" "internal-latency-prospect"))
(define E (standard-logbook-entry (default-logbook #:verbose? #t) "minimart" "internal-latency-syndicate"))
(define T (logbook-table E "internal-latency"
#:column-spec '(number-of-echoers
secs/msg