-
Notifications
You must be signed in to change notification settings - Fork 1
/
speed-test.lisp
63 lines (52 loc) · 2.8 KB
/
speed-test.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
(load "~/quicklisp/setup")
(asdf::load-asd (truename "./http2.asd"))
(ql:quickload "http2/server/example" :silent t)
(ql:quickload "hunchentoot" :silent t)
(ql:quickload 'cl-ppcre :silent t)
(ql:quickload 'woo :silent t)
(in-package :http2/server-example)
(bt:make-thread (lambda () (ignore-errors
(http2/server-example::run-demo-server :port 1237)))
:name "Our server thread")
(bt:make-thread (lambda () (ignore-errors
(http2::create-http-server 1238)))
:name "Our server thread")
(bt:make-thread
(lambda ()
(woo:run
(lambda (env)
(declare (ignore env))
'(200 (:content-type "text/plain") ("Hello, World")))
:port 1239)))
(hunchentoot:start (make-instance 'hunchentoot:easy-ssl-acceptor
:port 1235
:ssl-privatekey-file "/tmp/server.key"
:ssl-certificate-file "/tmp/server.crt"
:access-log-destination nil))
(hunchentoot:start (make-instance 'hunchentoot:easy-acceptor :port 1236
:access-log-destination nil))
(flet ((scan-port (base name &rest args )
(let ((res (uiop:run-program `("h2load" "-n" "5000"
,@args)
:output :string)))
(multiple-value-bind (match val)
(cl-ppcre:scan-to-strings "req/s[ :]*([0-9\\.]+)[ ]*([0-9\\.]+)[ ]*([0-9\\.]+)" res)
(let ((val-as-num (read-from-string (aref val 2))))
(format t "~40a ~10@a~@[~5@a%~]~%" name val-as-num
(when base (floor (/ val-as-num base 0.01))))
val-as-num)))))
(let ((base (scan-port nil "Hunchetoot over https" "https://localhost:1235")))
(scan-port base "HTTP/2 over TLS" "https://localhost:1237")
(scan-port base "HTTP/2 over plain socket" "http://localhost:1238")
(scan-port base "Hunchentoot on plain socket" "http://localhost:1236" "-p" "http/1.1")
(scan-port base "Woo on plain socket" "http://localhost:1239" "-p" "http/1.1")
(scan-port base "HTTP/2 over plain socket, -m20" "http://localhost:1238"
"-m" "20")
(scan-port base "Hunchentoot on plain socket, -m20" "http://localhost:1236"
"-p" "http/1.1" "-m" "20" )
(scan-port base "Woo on plain socket, -m20" "http://localhost:1239" "-p" "http/1.1"
"-m" "20" "-D1") ;this hangs when count-based for obvious reasons
(scan-port base "HTTP/2, plain socket, post " "http://localhost:1238"
"-d" "./client/client.lisp")
(scan-port base "Hunchentoot on plain socket, post" "http://localhost:1236" "-p" "http/1.1"
"-d" "./client/client.lisp")))