Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trying Spock / Scotty benchmark with updated Spock version #161

Open
vinothjustin opened this issue Aug 23, 2019 · 0 comments
Open

Trying Spock / Scotty benchmark with updated Spock version #161

vinothjustin opened this issue Aug 23, 2019 · 0 comments

Comments

@vinothjustin
Copy link

Hi,
I'm trying to run the benchmark(https://github.com/agrafix/Spock-scotty-benchmark) updating the Spock version to 0.13 but If I do, the metrics have gone down to ~6k request/sec from ~60k. Can you please let me know what I'm doing wrong? With the same code the scotty version works fine.
Scotty-results.txt
Spock-results.txt

{-# LANGUAGE OverloadedStrings #-}
module Main where

import System.Environment

import qualified Web.Scotty as Scotty
import Web.Spock
import Web.Spock.Config
import Data.Text (pack)

app :: SpockM () () () ()
app = do
  get "/echo/hello-world" $
    text "Hello World"

  get ("echo" <//> "plain" <//> var) $ \param ->
    text $ param

  get ("echo" <//> "regex" <//> var) $ \num ->
    text $ pack $ show (num::Int)

main =
    do args <- getArgs
       let port = 8181
       case args of
         ["scotty"] ->
             Scotty.scotty port $
             do Scotty.get "/echo/hello-world" $
                  Scotty.text "Hello World"
                Scotty.get "/echo/plain/:param" $
                  do p <- Scotty.param "param"
                     Scotty.text p
                Scotty.get (Scotty.regex "^/echo/regex/([0-9]+)$") $
                  do p <- Scotty.param "1"
                     Scotty.text p

         ["spock"] -> do
             cfg <- defaultSpockCfg () PCNoDatabase ()
             runSpock port (spock cfg app)

         _ -> putStrLn "Usage: ./Spock-scotty-benchmark spock|scotty"

and my cabal file changes are,

executable Spock-scotty-benchmark
  main-is:             Main.hs
  build-depends:       base >=4.12 && <4.13,
                       Spock >= 0.13,
                       scotty ==0.11.4,
                       text
  hs-source-dirs:      src
  default-language:    Haskell2010
  ghc-options:         -O3 -threaded

Any help would be highly appreciated, Thanks in advance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants