on master help sign in
Add another microbenchmark

--HG-- extra : convert_revision : 269f6f97beb84da276cd3bfe8e9a1add1d357713

commitda65102e7c50bb306a055a9a9e4805612108f81f authorBryan O'Sullivan <bos@serpentine.com> dateTue 19 Oct 2010, 04:09 (16 years ago) parent6ef71c2
1 file changed+26
tests/benchmarks/Equality.hs+26
tests/benchmarks/Equality.hsnew file+26
@@ -0,0 +1,26 @@
1+import System.Environment
2+import qualified Data.ByteString as B
3+import qualified Data.ByteString.Lazy as BL
4+import qualified Data.Text as T
5+import qualified Data.Text.Encoding as T
6+import qualified Data.Text.Lazy as TL
7+import qualified Data.Text.Lazy.Encoding as TL
8+
9+text needle haystack = do
10+ bs <- B.readFile haystack
11+ print . length . filter (==needle) . T.lines . T.decodeUtf8 $ bs
12+
13+lazyText needle haystack = do
14+ bs <- BL.readFile haystack
15+ print . length . filter (==needle) . TL.lines . TL.decodeUtf8 $ bs
16+
17+string needle haystack = do
18+ s <- readFile haystack
19+ print . length . filter (==needle) . lines $ s
20+
21+main = do
22+ args <- getArgs
23+ case args of
24+ ["text",n,h] -> text (T.pack n) h
25+ ["lazytext",n,h] -> lazyText (TL.pack n) h
26+ ["string",n,h] -> string n h