@@ -0,0 +1,20 @@
1+{-# LANGUAGE OverloadedStrings #-}
2+
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!
8+
9+import Control.Applicative
10+import Data.Text (Text)
11+import qualified Data.Attoparsec.Text as A
12+import qualified Data.Text as T
13+
14+testParser :: Text -> Either String Int
15+testParser f = fmap length -- avoid printing out the entire matched list
16+ . A.parseOnly (many ((() <$ A.string "b") <|> (() <$ A.anyChar)))
17+ $ f
18+
19+main :: IO ()
20+main = print . testParser $ T.replicate 50000 "a"