Skip to content

Commit

Permalink
Added fastcgi benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
snoyberg committed May 24, 2010
1 parent 8fc0fb4 commit 0144a2e
Show file tree
Hide file tree
Showing 21 changed files with 168 additions and 1 deletion.
2 changes: 2 additions & 0 deletions bigtable/c-fastcgi/Makefile
@@ -0,0 +1,2 @@
c-fastcgi: c-fastcgi.c
gcc -O2 -o c-fastcgi c-fastcgi.c -lfcgi
1 change: 1 addition & 0 deletions bigtable/c-fastcgi/bench
@@ -0,0 +1 @@
ab -n 100 -c 20 http://localhost:3000/app/ > c-fastcgi.ab
20 changes: 20 additions & 0 deletions bigtable/c-fastcgi/c-fastcgi.c
@@ -0,0 +1,20 @@
#include "fcgi_stdio.h" /* fcgi library; put it first*/

#include <stdlib.h>

void main(void)
{
while (FCGI_Accept() >= 0) {
int row;
printf("Content-type: text/html\r\n\r\n<table>");
for (row = 1000; row--;) {
int col;
printf("<tr>");
for (col = 1; col <= 50; ++col) {
printf("<td>%d</td>", col);
}
printf("</tr>");
}
printf("</table>");
}
}
14 changes: 14 additions & 0 deletions bigtable/c-fastcgi/lighttpd.conf
@@ -0,0 +1,14 @@
server.port = 3000
server.document-root = "."
server.modules = ("mod_fastcgi")

fastcgi.server = (
"/app" => ((
"socket" => "/tmp/test.fastcgi.socket",
"check-local" => "disable",
"bin-path" => "./c-fastcgi", # full path to executable
"min-procs" => 1,
"max-procs" => 4,
"idle-timeout" => 30
))
)
1 change: 1 addition & 0 deletions bigtable/c-fastcgi/run
@@ -0,0 +1 @@
lighttpd -D -f lighttpd.conf
2 changes: 2 additions & 0 deletions bigtable/direct-fastcgi/Makefile
@@ -0,0 +1,2 @@
fastcgi: fastcgi.hs
ghc --make fastcgi.hs
1 change: 1 addition & 0 deletions bigtable/direct-fastcgi/bench
@@ -0,0 +1 @@
ab -n 100 -c 20 http://localhost:3000/app/ > direct-fastcgi.ab
24 changes: 24 additions & 0 deletions bigtable/direct-fastcgi/fastcgi.hs
@@ -0,0 +1,24 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE PackageImports #-}
import Prelude hiding (putStr)
import Data.ByteString.Char8 (ByteString, putStr, pack)
import Numeric (showInt)
import qualified Data.ByteString.Lazy as L
import "direct-fastcgi" Network.FastCGI
import Control.Concurrent

main = acceptLoop forkIO app

app = do
setResponseHeader HttpContentType "text/html"
mapM_ fPut content

content = "<table>"
: foldr ($) ["</table>"] (replicate 1000 makeRow)

makeRow :: [ByteString] -> [ByteString]
makeRow rest = foldr (:) rest $ map makeCol [1..50]

makeCol 1 = "<tr><td>1</td>"
makeCol 50 = "<td>50</td></tr>"
makeCol i = pack $ '<' : 't' : 'd' : '>' : showInt i "</td>"
14 changes: 14 additions & 0 deletions bigtable/direct-fastcgi/lighttpd.conf
@@ -0,0 +1,14 @@
server.port = 3000
server.document-root = "."
server.modules = ("mod_fastcgi")

fastcgi.server = (
"/app" => ((
"socket" => "/tmp/test.fastcgi.socket",
"check-local" => "disable",
"bin-path" => "./fastcgi", # full path to executable
"min-procs" => 1,
"max-procs" => 4,
"idle-timeout" => 30
))
)
1 change: 1 addition & 0 deletions bigtable/direct-fastcgi/run
@@ -0,0 +1 @@
lighttpd -D -f lighttpd.conf
2 changes: 2 additions & 0 deletions bigtable/fastcgi/Makefile
@@ -0,0 +1,2 @@
fastcgi: fastcgi.hs
ghc --make fastcgi.hs -threaded
1 change: 1 addition & 0 deletions bigtable/fastcgi/bench
@@ -0,0 +1 @@
ab -n 100 -c 20 http://localhost:3000/app/ > package-fastcgi.ab
25 changes: 25 additions & 0 deletions bigtable/fastcgi/fastcgi.hs
@@ -0,0 +1,25 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE PackageImports #-}
import Prelude hiding (putStr)
import Data.ByteString.Char8 (ByteString, putStr, pack)
import Numeric (showInt)
import qualified Data.ByteString.Lazy as L
import "fastcgi" Network.FastCGI
import Network.CGI

main = runFastCGIConcurrent 5 app

app = do
setHeader "Content-Type" "text/html"
outputFPS content

content = L.fromChunks
$ "<table>"
: foldr ($) ["</table>"] (replicate 1000 makeRow)

makeRow :: [ByteString] -> [ByteString]
makeRow rest = foldr (:) rest $ map makeCol [1..50]

makeCol 1 = "<tr><td>1</td>"
makeCol 50 = "<td>50</td></tr>"
makeCol i = pack $ '<' : 't' : 'd' : '>' : showInt i "</td>"
14 changes: 14 additions & 0 deletions bigtable/fastcgi/lighttpd.conf
@@ -0,0 +1,14 @@
server.port = 3000
server.document-root = "."
server.modules = ("mod_fastcgi")

fastcgi.server = (
"/app" => ((
"socket" => "/tmp/test.fastcgi.socket",
"check-local" => "disable",
"bin-path" => "./fastcgi +RTS -N2", # full path to executable
"min-procs" => 1,
"max-procs" => 4,
"idle-timeout" => 30
))
)
1 change: 1 addition & 0 deletions bigtable/fastcgi/run
@@ -0,0 +1 @@
lighttpd -D -f lighttpd.conf
2 changes: 2 additions & 0 deletions bigtable/wai/fastcgi/Makefile
@@ -0,0 +1,2 @@
fastcgi: fastcgi.hs
ghc --make fastcgi.hs
1 change: 1 addition & 0 deletions bigtable/wai/fastcgi/bench
@@ -0,0 +1 @@
ab -n 100 -c 20 http://localhost:3000/app/ > fastcgi.ab
26 changes: 26 additions & 0 deletions bigtable/wai/fastcgi/fastcgi.hs
@@ -0,0 +1,26 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE PackageImports #-}
import Prelude hiding (putStr)
import Data.ByteString.Char8 (ByteString, putStr, pack)
import Numeric (showInt)
import "wai" Network.Wai
import Network.Wai.Enumerator
import Network.Wai.Handler.FastCGI
import qualified Data.ByteString.Lazy as L

main = run app

app _ = return $ Response Status200 [(ContentType, "text/html")] $ Right $
fromLBS content

content :: L.ByteString
content = L.fromChunks
$ "<table>"
: foldr ($) ["</table>"] (replicate 1000 makeRow)

makeRow :: [ByteString] -> [ByteString]
makeRow rest = foldr (:) rest $ map makeCol [1..50]

makeCol 1 = "<tr><td>1</td>"
makeCol 50 = "<td>50</td></tr>"
makeCol i = pack $ '<' : 't' : 'd' : '>' : showInt i "</td>"
14 changes: 14 additions & 0 deletions bigtable/wai/fastcgi/lighttpd.conf
@@ -0,0 +1,14 @@
server.port = 3000
server.document-root = "."
server.modules = ("mod_fastcgi")

fastcgi.server = (
"/app" => ((
"socket" => "/tmp/test.fastcgi.socket",
"check-local" => "disable",
"bin-path" => "./fastcgi-prof", # full path to executable
"min-procs" => 1,
"max-procs" => 1,
"idle-timeout" => 30
))
)
1 change: 1 addition & 0 deletions bigtable/wai/fastcgi/run
@@ -0,0 +1 @@
lighttpd -D -f lighttpd.conf
2 changes: 1 addition & 1 deletion bigtable/wai/simpleserver/simpleserver.hs
Expand Up @@ -15,7 +15,7 @@ app _ = return $ Response Status200 [(ContentType, "text/html")] $ Right $

content :: L.ByteString
content = L.fromChunks
$ "Content-Type: text/html\n\n<table>"
$ "<table>"
: foldr ($) ["</table>"] (replicate 1000 makeRow)

makeRow :: [ByteString] -> [ByteString]
Expand Down

0 comments on commit 0144a2e

Please sign in to comment.