git.iko.soy/typeable/attoparsec
on master help sign in
20 lines 698 B history raw
1{-# LANGUAGE OverloadedStrings #-}
3-- This benchmark reveals a huge performance regression that showed up
4-- under GHC 7.8.1 (https://github.com/bos/attoparsec/issues/56).
5--
6-- With GHC 7.6.3 and older, this program runs in 0.04 seconds. Under
7-- GHC 7.8.1 with (<|>) inlined, time jumps to 12 seconds!
9import Control.Applicative
10import Data.Text (Text)
11import qualified Data.Attoparsec.Text as A
12import qualified Data.Text as T
14testParser :: Text -> Either String Int
15testParser f = fmap length -- avoid printing out the entire matched list
16 . A.parseOnly (many ((() <$ A.string "b") <|> (() <$ A.anyChar)))
17 $ f
19main :: IO ()
20main = print . testParser $ T.replicate 50000 "a"