minimart-benchmark-2017/observe-all-minimart.rkt

69 lines
2.5 KiB
Racket

#lang racket/base
;; Measurement of presence processing.
;; Peers observe each other, but do not process the resulting routing events.
(require racket/match)
(require minimart)
(require logbook)
(provide run)
(struct presence (id) #:transparent)
(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))
;; (log-info "count for ~v is now ~v" id (+ count 1))
;; (log-info "~a" (gestalt->pretty-string g))
(transition (+ count 1) '())]
[_ #f]))
0
(gestalt-union (pub (presence id))
(sub (presence ?) #:level 1))))
(define boot-actions (for/list [(id (in-range peer-count))] (peer id)))
(define-values (results cpu-time wall-clock-time gc-time)
(time-apply (lambda () (run-ground boot-actions)) '()))
(values routing-update-count (max 1 (- cpu-time gc-time))))
(module+ main
(define E (standard-logbook-entry (default-logbook #:verbose? #t) "minimart" "observe-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))))