Adding WebSocket stress test and improving fit output

This commit is contained in:
Jay McCarthy 2010-08-19 16:32:55 -06:00
parent 1f61e7eb7f
commit 5eb8f181f6
2 changed files with 33 additions and 1 deletions

View File

@ -0,0 +1,32 @@
#lang racket/base
(require tests/stress/stress
net/websocket
net/url
racket/async-channel)
(fit "websocket echo server"
500
(λ (n)
(define confirm (make-async-channel))
(define shutdown!
(ws-serve #:port 0
#:confirmation-channel confirm
(λ (wsc _)
(let loop ()
(define m (ws-recv wsc))
(unless (eof-object? m)
(ws-send! wsc m)
(loop))))))
(define port (async-channel-get confirm))
(define THREADS 10)
(define REQS n)
(for-each thread-wait
(for/list ([t (in-range THREADS)])
(thread
(λ ()
(define conn (ws-connect (string->url (format "ws://localhost:~a" port))))
(for ([r (in-range REQS)])
(ws-send! conn "ping")
(ws-recv conn))))))))

View File

@ -20,7 +20,7 @@
(printf "~a: baseline = ~a\n" label baseline) (printf "~a: baseline = ~a\n" label baseline)
(for ([v (in-list l)]) (for ([v (in-list l)])
(match-define (vector n val) v) (match-define (vector n val) v)
(printf "\t~a: ~ax\n" n (/ val baseline)))) (printf "\t~a: ~ax\n" n (exact->inexact (/ val baseline)))))
(define (isolate trial-n thunk) (define (isolate trial-n thunk)
(define exp-cust (make-custodian)) (define exp-cust (make-custodian))