74 lines
2.6 KiB
Racket
74 lines
2.6 KiB
Racket
#lang racket/base
|
|
;; Measurement of presence processing.
|
|
;; Peers observe each other, AND ALSO process the resulting routing events.
|
|
|
|
(require racket/match)
|
|
(require minimart)
|
|
(require logbook)
|
|
|
|
(provide run)
|
|
|
|
(struct presence (id) #:transparent)
|
|
|
|
(define presence-proj (project-pubs (presence (?!))))
|
|
|
|
(define (run #:peer-count [peer-count 100])
|
|
(define routing-update-count 0)
|
|
|
|
(define (peer id)
|
|
(spawn (lambda (e count)
|
|
(match e
|
|
[(routing-update g)
|
|
(set! routing-update-count (+ routing-update-count 1))
|
|
(transition (for/fold [(count 0)]
|
|
[(i (gestalt-project/single g presence-proj))]
|
|
;; (log-info "Actor ~v adding ~v to ~v" id i count)
|
|
(+ count i))
|
|
'())]
|
|
[_ #f]))
|
|
0
|
|
(gestalt-union (pub (presence id))
|
|
(sub (presence ?) #:level 1))))
|
|
|
|
(define start-time (current-inexact-milliseconds))
|
|
(run-ground (for/list [(id (in-range peer-count))] (peer id)))
|
|
(define stop-time (current-inexact-milliseconds))
|
|
(define delta (- stop-time start-time))
|
|
(values routing-update-count delta))
|
|
|
|
(module+ main
|
|
(define E (standard-logbook-entry (default-logbook #:verbose? #t) "minimart" "sum-all-minimart"))
|
|
(define T (logbook-table E "presence-processing"
|
|
#:column-spec '(number-of-peers
|
|
secs/routing-update
|
|
routing-updates/sec
|
|
secs/peer
|
|
peers/sec
|
|
routing-update-count
|
|
run-duration-ms)))
|
|
;; Warmup
|
|
(let ()
|
|
(run #:peer-count 1)
|
|
(run #:peer-count 10)
|
|
(void))
|
|
;; Real run
|
|
(for ((n
|
|
(list* 1 2 5
|
|
(let loop ((n 10))
|
|
(if (>= n 100)
|
|
'()
|
|
(cons (inexact->exact (round n))
|
|
(loop (* n (sqrt (sqrt 2))))))))
|
|
))
|
|
(collect-garbage)
|
|
(collect-garbage)
|
|
(collect-garbage)
|
|
(define-values (routing-update-count run-duration-ms) (run #:peer-count n))
|
|
(write-logbook-datum! T (list n
|
|
(/ (/ run-duration-ms 1000.0) routing-update-count)
|
|
(/ routing-update-count (/ run-duration-ms 1000.0))
|
|
(/ (/ run-duration-ms 1000.0) n)
|
|
(/ n (/ run-duration-ms 1000.0))
|
|
routing-update-count
|
|
run-duration-ms))))
|