aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Benchmarks/RunHtmlBenchmarks.hs
diff options
context:
space:
mode:
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 ]