]> gitweb.factorcode.org Git - factor.git/blob - extra/webapps/benchmark/benchmark.factor
Switch to https urls
[factor.git] / extra / webapps / benchmark / benchmark.factor
1 ! Copyright (C) 2011 John Benediktsson
2 ! See https://factorcode.org/license.txt for BSD license
3
4 USING: accessors furnace.actions http.server
5 http.server.dispatchers http.server.responses http.server.static
6 io.servers kernel namespaces ;
7
8 IN: webapps.benchmark
9
10 : <hello-action> ( -- action )
11     <page-action>
12         [ "Hello, world!" <text-content> ] >>display ;
13
14 TUPLE: benchmark-dispatcher < dispatcher ;
15
16 : <benchmark-dispatcher> ( -- dispatcher )
17     benchmark-dispatcher new-dispatcher
18         <hello-action> "hello" add-responder
19         "resource:" <static> "static" add-responder ;
20
21 : run-benchmark-webapp ( -- )
22     <benchmark-dispatcher>
23         main-responder set-global
24     8080 httpd wait-for-server ;
25
26 ! Use this with apachebench:
27 !
28 !   * dynamic content
29 !     https://localhost:8080/hello
30 !
31 !   * static content
32 !     https://localhost:8080/static/readme.html
33
34 MAIN: run-benchmark-webapp