diff options
Diffstat (limited to 'src/Benchmarks/bigtable/hamlet.hs')
-rw-r--r-- | src/Benchmarks/bigtable/hamlet.hs | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/Benchmarks/bigtable/hamlet.hs b/src/Benchmarks/bigtable/hamlet.hs new file mode 100644 index 0000000..2778f2d --- /dev/null +++ b/src/Benchmarks/bigtable/hamlet.hs | |||
@@ -0,0 +1,33 @@ | |||
1 | -- | BigTable benchmark implemented using Hamlet. | ||
2 | -- | ||
3 | {-# LANGUAGE QuasiQuotes #-} | ||
4 | module Main where | ||
5 | |||
6 | import Criterion.Main | ||
7 | import Text.Hamlet | ||
8 | import Text.Hamlet.Monad | ||
9 | import Numeric (showInt) | ||
10 | import Data.Text (Text) | ||
11 | import qualified Data.Text as T | ||
12 | import Data.Maybe (fromJust) | ||
13 | |||
14 | main = defaultMain | ||
15 | [ bench "bigTable" $ nf bigTable bigTableData | ||
16 | ] | ||
17 | where | ||
18 | rows :: Int | ||
19 | rows = 1000 | ||
20 | |||
21 | bigTableData :: [[Int]] | ||
22 | bigTableData = replicate rows [1..10] | ||
23 | {-# NOINLINE bigTableData #-} | ||
24 | |||
25 | bigTable rows = fromJust $ hamletToText undefined [$hamlet| | ||
26 | %table | ||
27 | $forall rows row | ||
28 | %tr | ||
29 | $forall row cell | ||
30 | %td $showInt'.cell$ | ||
31 | |] | ||
32 | where | ||
33 | showInt' i = Encoded $ T.pack $ showInt i "" | ||