on master help sign in
Shorten Equality benchmark
80ce7fbBryan O'Sullivan
tests/benchmarks/Equality.hs+9−14
@@ -6,25 +6,20 @@ import qualified Data.Text.Encoding as T
6import qualified Data.Text.Lazy as TL
6import qualified Data.Text.Lazy as TL
7import qualified Data.Text.Lazy.Encoding as TL
7import qualified Data.Text.Lazy.Encoding as TL
8
8
9−bytestring haystack = do
9+func :: (Eq a) => [a] -> IO ()
10− ls <- B.lines `fmap` B.readFile haystack
10+func ls =
11 print . sum . map (\needle -> length . filter (==needle) $ ls) $ take 100 ls
11 print . sum . map (\needle -> length . filter (==needle) $ ls) $ take 100 ls
12
12
13−lazyBytestring haystack = do
14− ls <- BL.lines `fmap` BL.readFile haystack
13+bytestring haystack = func =<< B.lines `fmap` B.readFile haystack
15− print . sum . map (\needle -> length . filter (==needle) $ ls) $ take 100 ls
16
14
17−text haystack = do
18− ls <- (T.lines . T.decodeUtf8) `fmap` B.readFile haystack
15+lazyBytestring haystack = func =<< BL.lines `fmap` BL.readFile haystack
19− print . sum . map (\needle -> length . filter (==needle) $ ls) $ take 100 ls
20
16
21−lazyText haystack = do
22− ls <- (TL.lines . TL.decodeUtf8) `fmap` BL.readFile haystack
17+text haystack = func =<< (T.lines . T.decodeUtf8) `fmap` B.readFile haystack
23− print . sum . map (\needle -> length . filter (==needle) $ ls) $ take 100 ls
24
18
25−string haystack = do
19+lazyText haystack = func =<<
20+ (TL.lines . TL.decodeUtf8) `fmap` BL.readFile haystack
21+
26− ls <- lines `fmap` readFile haystack
22+string haystack = func =<< lines `fmap` readFile haystack
27− print . sum . map (\needle -> length . filter (==needle) $ ls) $ take 100 ls
28
23
29main = do
24main = do
30 args <- getArgs
25 args <- getArgs