Adding WebSocket stress test and improving fit output
This commit is contained in:
parent
1f61e7eb7f
commit
5eb8f181f6
32
collects/tests/stress/net/websocket.rkt
Normal file
32
collects/tests/stress/net/websocket.rkt
Normal 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))))))))
|
|
@ -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))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user