diff options
author | Johannes Gerer <oss@johannesgerer.com> | 2016-10-26 02:07:02 +0200 |
---|---|---|
committer | Johannes Gerer <oss@johannesgerer.com> | 2016-10-26 02:07:02 +0200 |
commit | 675085c2e0b0b851378da08b7d73024766107c87 (patch) | |
tree | 5a927de4a9576aef7e6129b96e74aa5c96f9ffb6 /src/Benchmarks/RunHtmlBenchmarks.hs | |
download | blazeT-675085c2e0b0b851378da08b7d73024766107c87.tar.gz blazeT-675085c2e0b0b851378da08b7d73024766107c87.tar.zst blazeT-675085c2e0b0b851378da08b7d73024766107c87.zip |
Initial
Diffstat (limited to 'src/Benchmarks/RunHtmlBenchmarks.hs')
-rw-r--r-- | src/Benchmarks/RunHtmlBenchmarks.hs | 36 |
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 | -- | ||
4 | module Benchmarks.RunHtmlBenchmarks where | ||
5 | |||
6 | import Criterion.Main | ||
7 | import qualified Data.Text.Lazy as LT | ||
8 | import Data.List | ||
9 | import qualified Data.ByteString.Lazy as LB | ||
10 | |||
11 | import qualified Text.Blaze.Renderer.Utf8 as Utf8 | ||
12 | import qualified Text.Blaze.Renderer.String as String | ||
13 | import qualified Text.Blaze.Renderer.Text as Text | ||
14 | |||
15 | import Benchmarks.HtmlBenchmarks (HtmlBenchmark (..), benchmarks) | ||
16 | import qualified Benchmarks.BlazeTBenchmarks as BT (HtmlBenchmark (..), benchmarks) | ||
17 | import qualified Text.BlazeT.Renderer.Utf8 as TUtf8 | ||
18 | import qualified Text.BlazeT.Renderer.String as TString | ||
19 | import qualified Text.BlazeT.Renderer.Text as TText | ||
20 | |||
21 | -- | Function to run the benchmarks using criterion | ||
22 | -- | ||
23 | main :: IO () | ||
24 | main = 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 | ] | ||