git.iko.soy/typeable/html-parse
on ff88508 help sign in
typeable/html-parse/Benchmark.hs
29 lines 1.2 kB history raw
1import Criterion.Main
2import qualified Data.Text.IO as TIO
3import Control.DeepSeq
4import qualified Text.HTML.TagSoup as Soup
5import qualified Text.HTML.Parser as Me
7main :: IO ()
8main = do
9 t <- TIO.readFile "test.html"
10 defaultMain
11 [ bgroup "Forced"
12 [ bench "tagsoup fast Text" $ nf (Soup.parseTagsOptions Soup.parseOptionsFast) t
13 , bench "tagsoup normal Text" $ nf (Soup.parseTagsOptions Soup.parseOptions) t
14 , bench "html-parser" $ nf Me.parseTokens t
15 ]
16 , bgroup "length"
17 [ bench "tagsoup fast Text" $ whnf (length . Soup.parseTagsOptions Soup.parseOptionsFast) t
18 , bench "tagsoup normal Text" $ whnf (length . Soup.parseTagsOptions Soup.parseOptions) t
19 , bench "html-parser" $ whnf (length . Me.parseTokens) t
20 ]
21 ]
23instance NFData t => NFData (Soup.Tag t) where
24 rnf (Soup.TagOpen t attrs) = rnf t `seq` rnf attrs `seq` ()
25 rnf (Soup.TagClose t) = rnf t `seq` ()
26 rnf (Soup.TagText t) = rnf t `seq` ()
27 rnf (Soup.TagComment t) = rnf t `seq` ()
28 rnf (Soup.TagWarning t) = rnf t `seq` ()
29 rnf (Soup.TagPosition _ _) = ()