[Haskell-cafe] RE: Substring replacements (was: Differences in optimisiation ...)

Branimir Maksimovic bmaxa at hotmail.com
Sat Dec 10 20:09:00 EST 2005




>From: Daniel Fischer <daniel.is.fischer at web.de>
>To: "Branimir Maksimovic" <bmaxa at hotmail.com>
>CC: Haskell-Cafe at haskell.org
>Subject: Substring replacements (was: Differences in optimisiation ...)
>Date: Sat, 10 Dec 2005 22:56:10 +0100
>
>and if you try it on
>
>main2 :: IO ()
>main2 = let src = replicate 1000 'r'
>             dst = " # "
>	    str = replicate 999 'r' ++ 'c': replicate 1000 'r'
>	    out = replace src dst $ concat $ replicate 500 str
>	    out1 = replace src dst $ concat $ replicate 501 str
>	in do putStrLn $ "Working very long"
>	      putStrLn $ show (out == out1) ++ "\nDone"
>
>you'll see a real difference. I'm not sure, why your algorithm pays a so 
>much
>higher penalty, though. Maybe, it'll be faster if you make searchr' &c 
>local
>functions? I'll try.
>

Well, this is on my machine with your setup and -O2 flag:
$ time replace.exe
Working very long
False
Done

real    0m31.828s
user    0m0.015s
sys     0m0.000s

bmaxa at MAXA ~/tutorial
$ time searchr.exe
Working very long
False
Done

real    0m37.531s
user    0m0.015s
sys     0m0.000s

bmaxa at MAXA ~/tutorial
$ time srchrep.exe
Working very long
False
Done

real    0m18.047s
user    0m0.015s
sys     0m0.015s

bmaxa at MAXA ~/tutorial
$ time replace1.exe
Working very long
False
Done

real    0m12.531s
user    0m0.015s
sys     0m0.000s

replace1 is Bulat's newest algorithm. It is really incredibly fastest with 
this setup.

Greetings, Bane.

_________________________________________________________________
FREE pop-up blocking with the new MSN Toolbar - get it now! 
http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/



More information about the Haskell-Cafe mailing list