Support more (optional) waypoints

This commit is contained in:
Tony Garnock-Jones 2014-05-05 11:33:50 -04:00
parent 1c33949f3b
commit ae15b002c7
2 changed files with 27 additions and 11 deletions

View File

@ -9,9 +9,13 @@
(define server-entry-type #f) (define server-entry-type #f)
(define server-hostname "localhost") (define server-hostname "localhost")
(define server-port 5999) (define server-port 5999)
(define max-waypoint 1000)
(command-line #:program "echo-client.rkt" (command-line #:program "echo-client.rkt"
#:once-each #:once-each
["--max-waypoint" n
"set maximum waypoint for this run"
(set! max-waypoint (string->number n))]
["--host" name ["--host" name
"set hostname of server to contact" "set hostname of server to contact"
(set! server-hostname name)] (set! server-hostname name)]
@ -49,7 +53,12 @@
(define waypoints (define waypoints
(list 1 10 20 30 40 50 60 70 80 90 100 120 (list 1 10 20 30 40 50 60 70 80 90 100 120
150 200 210 220 230 240 250 260 270 280 290 300 400 150 200 210 220 230 240 250 260 270 280 290 300 400
500 600 700 800 900)) 500 600 700 800 900
;; Here on up, increase by ~1.2× each time
1000 1200 1440 1728 2073
2488 2985 3583 4299 5159
6191 7430 8916 10699 12839
15407 18488 22186 26623 31947))
;; We exchange pings with the server for this many milliseconds before ;; We exchange pings with the server for this many milliseconds before
;; moving up to the next waypoint. ;; moving up to the next waypoint.
@ -123,18 +132,20 @@
(match remaining-waypoints (match remaining-waypoints
['() (void)] ['() (void)]
[(cons next-waypoint rest) [(cons next-waypoint rest)
(grow-to-waypoint next-waypoint) (when (<= next-waypoint max-waypoint)
(log-info "At waypoint ~a" next-waypoint) (grow-to-waypoint next-waypoint)
(when (equal? remaining-waypoints waypoints) ;; First ever waypoint. Do some warmup. (log-info "At waypoint ~a" next-waypoint)
(log-info "Warming up.") (when (equal? remaining-waypoints waypoints) ;; First ever waypoint. Do some warmup.
(ping-randomly #f) (log-info "Warming up.")
(log-info "Warmup complete. Proceeding with real measurements.")) (ping-randomly #f)
(ping-randomly) (log-info "Warmup complete. Proceeding with real measurements."))
(loop rest)])) (ping-randomly)
(loop rest))]))
(let () (let ()
(write-logbook-datum! Tsummary #:label "server-hostname" server-hostname) (write-logbook-datum! Tsummary #:label "server-hostname" server-hostname)
(write-logbook-datum! Tsummary #:label "server-port" server-port) (write-logbook-datum! Tsummary #:label "server-port" server-port)
(write-logbook-datum! Tsummary #:label "waypoints" waypoints)
(write-logbook-datum! Tsummary #:label "ping-time" ping-time) (write-logbook-datum! Tsummary #:label "ping-time" ping-time)
(write-logbook-datum! Tsummary #:label "max-waypoint" max-waypoint)
(write-logbook-datum! Tsummary #:label "waypoints" waypoints)
(void)) (void))

View File

@ -9,10 +9,14 @@
(define server-variation #f) (define server-variation #f)
(define server-hostname "localhost") (define server-hostname "localhost")
(define max-waypoint #f)
(command-line #:program "external-latency.rkt" (command-line #:program "external-latency.rkt"
#:once-each #:once-each
["--host" name "hostname where server is reachable" (set! server-hostname name)] ["--host" name "hostname where server is reachable" (set! server-hostname name)]
["--max-waypoint" n
"set maximum waypoint for this run"
(set! max-waypoint (string->number n))]
#:once-any #:once-any
["--erlang" "use erlang server" (set! server-variation 'erlang)] ["--erlang" "use erlang server" (set! server-variation 'erlang)]
["--minimart" "use minimart server" (set! server-variation 'minimart)] ["--minimart" "use minimart server" (set! server-variation 'minimart)]
@ -65,7 +69,8 @@
(log-info "Starting client...") (log-info "Starting client...")
(define client-control (define client-control
(start-bg (start-bg
(format "racket echo-client.rkt --host ~a --logbook-entry-name ~a --logbook-entry-type ~a" (format "racket echo-client.rkt ~a--host ~a --logbook-entry-name ~a --logbook-entry-type ~a"
(if max-waypoint (format "--max-waypoint ~a " max-waypoint) "")
server-hostname server-hostname
entry-name entry-name
entry-type))) entry-type)))