From dd280eae9a4629b8d287235ae0194ad6563e44e9 Mon Sep 17 00:00:00 2001
From: John Benediktsson <mrjbq7@gmail.com>
Date: Fri, 26 Aug 2011 18:02:44 -0700
Subject: [PATCH] Adding a webapp for benchmarking the Factor web server.

---
 extra/webapps/benchmark/benchmark.factor | 34 ++++++++++++++++++++++++
 1 file changed, 34 insertions(+)
 create mode 100644 extra/webapps/benchmark/benchmark.factor

diff --git a/extra/webapps/benchmark/benchmark.factor b/extra/webapps/benchmark/benchmark.factor
new file mode 100644
index 0000000000..8f6154cc50
--- /dev/null
+++ b/extra/webapps/benchmark/benchmark.factor
@@ -0,0 +1,34 @@
+! Copyright (C) 2011 John Benediktsson
+! See http://factorcode.org/license.txt for BSD license
+
+USING: accessors furnace.actions http.server
+http.server.dispatchers http.server.responses http.server.static
+kernel namespaces ;
+
+IN: webapps.benchmark
+
+: <hello-action> ( -- action )
+    <page-action>
+        [ "Hello, world!" "text/plain" <content> ] >>display ;
+
+TUPLE: benchmark < dispatcher ;
+
+: <benchmark> ( -- dispatcher )
+    benchmark new-dispatcher
+        <hello-action> "hello" add-responder
+        "resource:" <static> "static" add-responder ;
+
+: run-benchmark ( -- )
+    <benchmark>
+        main-responder set-global
+    8080 httpd drop ;
+
+! Use this with apachebench:
+!
+!   * dynamic content
+!     http://localhost:8080/hello
+!
+!   * static content
+!     http://localhost:8080/static/readme.html
+
+MAIN: run-benchmark