Fix internal-latency-syndicate.rkt
This commit is contained in:
parent
63146632fe
commit
b3be7a8e83
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue