From 60ae398df46a6419772296d2c0f32c4af40c9a82 Mon Sep 17 00:00:00 2001 From: Marco Zocca Date: Mon, 1 Jan 2024 22:42:05 +0100 Subject: [PATCH] fix bench --- Web/Scotty/Action.hs | 1 - bench/Main.hs | 7 +++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Web/Scotty/Action.hs b/Web/Scotty/Action.hs index 8dd8036..168fce1 100644 --- a/Web/Scotty/Action.hs +++ b/Web/Scotty/Action.hs @@ -73,7 +73,6 @@ import Control.Monad.Trans.Resource (withInternalState, runResourceT) import Control.Concurrent.MVar import qualified Data.Aeson as A --- import Data.Bifunctor (bimap, first) import Data.Bool (bool) import qualified Data.ByteString.Char8 as B import qualified Data.ByteString.Lazy.Char8 as BL diff --git a/bench/Main.hs b/bench/Main.hs index 73eccee..5538d4d 100644 --- a/bench/Main.hs +++ b/bench/Main.hs @@ -6,6 +6,7 @@ module Main (main) where import Control.Monad +import Control.Monad.Trans.Resource (withInternalState, runResourceT) import Data.Functor.Identity import Lucid.Base import Lucid.Html5 @@ -19,16 +20,18 @@ import Weigh main :: IO () main = do + withRes $ \istate -> mainWith $ do setColumns [Case,Allocated,GCs,Live,Check,Max,MaxOS] setFormat Markdown io "ScottyM Strict" BL.putStr - (SS.evalState (runS $ renderBST htmlScotty) (defaultScottyState)) + (SS.evalState (runS $ renderBST htmlScotty) (defaultScottyState istate)) io "ScottyM Lazy" BL.putStr - (SL.evalState (runScottyLazy $ renderBST htmlScottyLazy) (defaultScottyState)) + (SL.evalState (runScottyLazy $ renderBST htmlScottyLazy) (defaultScottyState istate)) io "Identity" BL.putStr (runIdentity $ renderBST htmlIdentity) +withRes = runResourceT . withInternalState htmlTest :: Monad m => HtmlT m () htmlTest = replicateM_ 2 $ div_ $ do