Created
September 1, 2012 08:12
-
-
Save lbolla/3567006 to your computer and use it in GitHub Desktop.
Warp vs. Yesod benchmark
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GHC=ghc --make -O2 #-threaded | |
GHC_PROF=${GHC} -prof -auto-all | |
warp: warp.hs | |
${GHC} warp.hs | |
warp-prof: warp.hs | |
${GHC_PROF} warp.hs | |
yesod: yesod.hs | |
${GHC} yesod.hs | |
yesod-prof: yesod.hs | |
${GHC_PROF} yesod.hs | |
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" | |
clean: | |
rm -f *.hi *.o warp yesod |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tornado.httpserver | |
import tornado.ioloop | |
import tornado.web | |
class ServeHTTP(tornado.web.RequestHandler): | |
def get(self): | |
self.write("Hello World") | |
urls = [ | |
(r"/", ServeHTTP) | |
] | |
app = tornado.web.Application(urls) | |
if __name__ == "__main__": | |
server = tornado.httpserver.HTTPServer(app) | |
server.listen(8080) | |
tornado.ioloop.IOLoop.instance().start() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE TypeFamilies, QuasiQuotes, MultiParamTypeClasses, TemplateHaskell #-} | |
import Yesod | |
data HelloWorld = HelloWorld | |
mkYesod "HelloWorld" [parseRoutes| | |
/ HomeR GET | |
|] | |
-- Disable session | |
instance Yesod HelloWorld where | |
makeSessionBackend = const $ return Nothing | |
-- Disable Hamlet | |
getHomeR = return . RepPlain . toContent $ "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