File: Main.hs

package info (click to toggle)
haskell-scotty 0.11.6%2Bdfsg-1
  • links: PTS
  • area: main
  • in suites: bullseye
  • size: 232 kB
  • sloc: haskell: 1,369; makefile: 6
file content (54 lines) | stat: -rw-r--r-- 1,369 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
{-# language
    OverloadedStrings
  , GeneralizedNewtypeDeriving
  #-}

module Main (main) where

import Control.Monad
import Data.Default.Class (def)
import Data.Functor.Identity
import Data.Text (Text)
import Lucid.Base
import Lucid.Html5
import Web.Scotty
import Web.Scotty.Internal.Types
import qualified Control.Monad.State.Lazy as SL
import qualified Control.Monad.State.Strict as SS
import qualified Data.ByteString.Lazy as BL

import Weigh

main :: IO ()
main = do
  mainWith $ do
    setColumns [Case,Allocated,GCs,Live,Check,Max,MaxOS]
    setFormat Markdown
    io "ScottyM Strict" BL.putStr
      (SS.evalState (runS $ renderBST htmlScotty) def)
    io "ScottyM Lazy" BL.putStr
      (SL.evalState (runScottyLazy $ renderBST htmlScottyLazy) def)
    io "Identity" BL.putStr
      (runIdentity $ renderBST htmlIdentity)

htmlTest :: Monad m => HtmlT m ()
htmlTest = replicateM_ 2 $ div_ $ do
  replicateM_ 1000 $ div_ $ do
    replicateM_ 10000 $ div_ "test"

htmlIdentity :: HtmlT Identity ()
htmlIdentity = htmlTest
{-# noinline htmlIdentity #-}

htmlScotty :: HtmlT ScottyM ()
htmlScotty = htmlTest
{-# noinline htmlScotty #-}

htmlScottyLazy :: HtmlT ScottyLazy ()
htmlScottyLazy = htmlTest
{-# noinline htmlScottyLazy #-}

newtype ScottyLazy a = ScottyLazy
  { runScottyLazy:: SL.State (ScottyState Text IO) a }
  deriving (Functor,Applicative,Monad)