Skip to content

Commit

Permalink
Add Daniel's replace benchmark
Browse files Browse the repository at this point in the history
--HG--
extra : convert_revision : fc7c0924637fe3b5b3e3aec743fa1f7a8bda57f0
  • Loading branch information
bos committed Sep 8, 2010
1 parent cfe95e8 commit 64c35c5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion tests/benchmarks/Makefile
Expand Up @@ -4,7 +4,7 @@ CPPFLAGS := $(shell icu-config --cppflags)
LDFLAGS := $(CFLAGS) $(shell icu-config --ldflags --ldflags-icuio)
ghc := ghc

all := FileRead FileRead_prof fileread_c
all := FileRead FileRead_prof Replace Replace_prof fileread_c

all: $(all)

Expand Down
21 changes: 21 additions & 0 deletions tests/benchmarks/Replace.hs
@@ -0,0 +1,21 @@
{-# LANGUAGE BangPatterns #-}
module Main (main) where

import System.Environment (getArgs)
import qualified Data.Text.Lazy as LT
import qualified Data.Text.Lazy.IO as LT
import qualified Data.ByteString.Lazy.Search as LB
import qualified Data.ByteString.Lazy.Char8 as LB
import qualified Data.ByteString.Char8 as B

lazyText file pat sub =
LT.readFile file >>= LT.putStr . LT.replace (LT.pack pat) (LT.pack sub)

lazyBS file pat sub =
LB.readFile file >>= LB.putStr . LB.replace (B.pack pat) (LB.pack sub)

main = do
(kind : file : pat : sub : _) <- getArgs
case kind of
"lazyText" -> lazyText file pat sub
"lazyBS" -> lazyBS file pat sub

0 comments on commit 64c35c5

Please sign in to comment.