Created
May 16, 2011 13:56
-
-
Save jaspervdj/974481 to your computer and use it in GitHub Desktop.
Haskell implementation of the benchmark described at: <http://www.ostinelli.net/a-comparison-between-misultin-mochiweb-cowboy-nodejs-and-tornadoweb/>
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
-- | This is a Haskell implementation of the benchmark published at: | |
-- | |
-- <http://www.ostinelli.net/a-comparison-between-misultin-mochiweb-cowboy-nodejs-and-tornadoweb/> | |
-- | |
-- It is pretty fast as well. It uses WAI and the Warp server. I didn't really | |
-- bother with using any web framework, since it's such a small benchmark. | |
-- | |
{-# LANGUAGE OverloadedStrings #-} | |
module Main where | |
import Control.Monad (join) | |
import Data.Monoid (mappend) | |
import Blaze.ByteString.Builder.ByteString (fromByteString) | |
import Network.Wai (Application, Request (..), Response (..)) | |
import Network.Wai.Handler.Warp (run) | |
import Network.HTTP.Types (statusOK) | |
application :: Application | |
application query = return $ ResponseBuilder statusOK headers $ case value of | |
Just v -> fromByteString "<http_test><value>" `mappend` | |
fromByteString v `mappend` fromByteString "</value></http_test>" | |
Nothing -> fromByteString | |
"<http_test><error>no value specified</error></http_test>" | |
where | |
value = join $ lookup "value" (queryString query) | |
headers = [("Content-Type", "text/xml")] | |
main :: IO () | |
main = run 8000 application |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment