Skip to content

Instantly share code, notes, and snippets.

@lbolla
Created September 1, 2012 08:12
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lbolla/3567006 to your computer and use it in GitHub Desktop.
Save lbolla/3567006 to your computer and use it in GitHub Desktop.
Warp vs. Yesod benchmark
warp: warp.hs
ghc --make -O2 warp.hs
warp-prof: warp.hs
ghc --make -prof -auto-all -O2 warp.hs -o warp-prof
yesod: yesod.hs
ghc --make -O2 yesod.hs
yesod-prof: yesod.hs
ghc --make -prof -auto-all -O2 yesod.hs -o yesod-prof
bench:
httperf --hog --client=0/1 --server=localhost --port=8080 --uri=/ --rate=1000 --send-buffer=4096 --recv-buffer=16384 --num-conns=100 --num-calls=100 --burst-length=20 | grep "^Request rate"
{-# LANGUAGE OverloadedStrings #-}
import Network.Wai
import Network.HTTP.Types
import Network.Wai.Handler.Warp (run)
import Data.ByteString.Lazy.Char8 ()
app :: Application
app _ = return $ responseLBS
status200
[("Content-Type", "text/html")]
"Hello World!"
main :: IO ()
main = do
putStrLn "http://localhost:8080/"
run 8080 app
{-# LANGUAGE TypeFamilies, QuasiQuotes, MultiParamTypeClasses, TemplateHaskell #-}
import Yesod
data HelloWorld = HelloWorld
mkYesod "HelloWorld" [parseRoutes|
/ HomeR GET
|]
instance Yesod HelloWorld
getHomeR :: Handler RepHtml
getHomeR = defaultLayout [whamlet|$newline always
Hello World!
|]
main :: IO ()
main = warp 8080 HelloWorld
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment