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