aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Benchmarks/RunHtmlBenchmarks.hs
diff options
context:
space:
mode:
authorJohannes Gerer <oss@johannesgerer.com>2016-10-26 02:07:02 +0200
committerJohannes Gerer <oss@johannesgerer.com>2016-10-26 02:07:02 +0200
commit675085c2e0b0b851378da08b7d73024766107c87 (patch)
tree5a927de4a9576aef7e6129b96e74aa5c96f9ffb6 /src/Benchmarks/RunHtmlBenchmarks.hs
downloadblazeT-675085c2e0b0b851378da08b7d73024766107c87.tar.gz
blazeT-675085c2e0b0b851378da08b7d73024766107c87.tar.zst
blazeT-675085c2e0b0b851378da08b7d73024766107c87.zip
Initial
Diffstat (limited to 'src/Benchmarks/RunHtmlBenchmarks.hs')
-rw-r--r--src/Benchmarks/RunHtmlBenchmarks.hs36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/Benchmarks/RunHtmlBenchmarks.hs b/src/Benchmarks/RunHtmlBenchmarks.hs
new file mode 100644
index 0000000..04c28ff
--- /dev/null
+++ b/src/Benchmarks/RunHtmlBenchmarks.hs
@@ -0,0 +1,36 @@
1-- | This is a module which runs the 'HtmlBenchmarks' module using the different
2-- renderers available.
3--
4module Benchmarks.RunHtmlBenchmarks where
5
6import Criterion.Main
7import qualified Data.Text.Lazy as LT
8import Data.List
9import qualified Data.ByteString.Lazy as LB
10
11import qualified Text.Blaze.Renderer.Utf8 as Utf8
12import qualified Text.Blaze.Renderer.String as String
13import qualified Text.Blaze.Renderer.Text as Text
14
15import Benchmarks.HtmlBenchmarks (HtmlBenchmark (..), benchmarks)
16import qualified Benchmarks.BlazeTBenchmarks as BT (HtmlBenchmark (..), benchmarks)
17import qualified Text.BlazeT.Renderer.Utf8 as TUtf8
18import qualified Text.BlazeT.Renderer.String as TString
19import qualified Text.BlazeT.Renderer.Text as TText
20
21-- | Function to run the benchmarks using criterion
22--
23main :: IO ()
24main = defaultMain $ zipWith g benchmarks BT.benchmarks
25 where
26 g x y = bgroup (hName x) $ benchHtml x ++ benchHtml2 y
27 benchHtml (HtmlBenchmark _ f x _) =
28 [ bench "Utf8" $ nf (LB.length . Utf8.renderMarkup . f) x
29 , bench "String" $ nf (String.renderMarkup . f) x
30 , bench "Text" $ nf (LT.length . Text.renderMarkup . f) x
31 ]
32 benchHtml2 (BT.HtmlBenchmark _ f x _) =
33 [ bench "BlazeT.Utf8" $ nf (LB.length . TUtf8.renderMarkup . f) x
34 , bench "BlazeT.String" $ nf (TString.renderMarkup . f) x
35 , bench "BlazeT.Text" $ nf (LT.length . TText.renderMarkup . f) x
36 ]