Repository: couchdb-mochiweb
Updated Branches:
  refs/heads/upstream b66b68d95 -> bd6ae7cbb


add benchmarking for mochiweb

Add a benchmark-script, and add `make bench` which creates an app
for the benchmark. Additionally add a new route to the sample app
to have a benchmark that is not dependent on the file system.


Project: http://git-wip-us.apache.org/repos/asf/couchdb-mochiweb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-mochiweb/commit/f01872e2
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-mochiweb/tree/f01872e2
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-mochiweb/diff/f01872e2

Branch: refs/heads/upstream
Commit: f01872e2ac30e21a5bb41765fb14f49ec026be1e
Parents: b66b68d
Author: Robert Kowalski <r...@kowalski.gd>
Authored: Mon Jul 20 00:19:12 2015 +0200
Committer: Robert Kowalski <r...@kowalski.gd>
Committed: Tue Jul 28 20:58:45 2015 +0200

----------------------------------------------------------------------
 Makefile                                        |  6 ++++++
 support/bench.sh                                | 21 ++++++++++++++++++++
 .../mochiwebapp_skel/src/mochiapp_web.erl       |  3 +++
 3 files changed, 30 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-mochiweb/blob/f01872e2/Makefile
----------------------------------------------------------------------
diff --git a/Makefile b/Makefile
index 33601c7..a7914ee 100644
--- a/Makefile
+++ b/Makefile
@@ -21,3 +21,9 @@ clean:
 
 app:
        @$(REBAR) -r create template=mochiwebapp dest=$(DEST) appid=$(PROJECT)
+
+bench: app
+       @echo "Writing $(DEST)/$(PROJECT).sh"
+       @cp support/bench.sh $(DEST)/bench.sh
+       @perl -p -i -e "s/-s reloader/-s reloader\n    -detached/g" 
$(DEST)/start-dev.sh
+       @perl -p -i -e "s/-s reloader/-s reloader \\\/g" $(DEST)/start-dev.sh

http://git-wip-us.apache.org/repos/asf/couchdb-mochiweb/blob/f01872e2/support/bench.sh
----------------------------------------------------------------------
diff --git a/support/bench.sh b/support/bench.sh
new file mode 100755
index 0000000..7af4c69
--- /dev/null
+++ b/support/bench.sh
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+SERVER_IP=""
+
+if test ! -n "$SERVER_IP"; then
+    echo "error: please set SERVER_IP"
+    exit 1
+fi
+
+BENCH_RUN="siege -q -c400 -r100 -b http://$SERVER_IP:8080/hello_world";
+
+sleep 120
+
+echo ""
+echo ""
+for i in `seq 1 10`;
+do
+    echo "Running test #$i:"
+    $BENCH_RUN
+    sleep 90
+done

http://git-wip-us.apache.org/repos/asf/couchdb-mochiweb/blob/f01872e2/support/templates/mochiwebapp_skel/src/mochiapp_web.erl
----------------------------------------------------------------------
diff --git a/support/templates/mochiwebapp_skel/src/mochiapp_web.erl 
b/support/templates/mochiwebapp_skel/src/mochiapp_web.erl
index 5fe455a..8429a88 100644
--- a/support/templates/mochiwebapp_skel/src/mochiapp_web.erl
+++ b/support/templates/mochiwebapp_skel/src/mochiapp_web.erl
@@ -26,6 +26,9 @@ loop(Req, DocRoot) ->
         case Req:get(method) of
             Method when Method =:= 'GET'; Method =:= 'HEAD' ->
                 case Path of
+                  "hello_world" ->
+                    Req:respond({200, [{"Content-Type", "text/plain"}],
+                    "Hello world!\n"});
                     _ ->
                         Req:serve_file(Path, DocRoot)
                 end;

Reply via email to