[Haskell-cafe] Progress on shootout entries

Sebastian Sylvan sebastian.sylvan at gmail.com
Tue Jan 3 21:02:29 EST 2006

On 1/3/06, Chris Kuklewicz <haskell at list.mightyreason.com> wrote:
> Hello,
>   Where there were no entries to the
> http://shootout.alioth.debian.org/benchmark.php?test=chameneos&lang=all
> benchmark, there are now two.  The one by Josh Goldfoot is already
> posted, the one Einar Karttunen and I optimized has been submitted and
> will run faster/smaller.  Our code is at
> http://haskell.org/hawiki/ChameneosEntry
>   Now for improving the fasta benchmark,
> http://shootout.alioth.debian.org/benchmark.php?test=fasta&lang=all ,
> which currently has a space leak in the Haskell entry.
>   A non-leaking version which has been optimized to run 3.5 times faster
> is now up at http://haskell.org/hawiki/FastaEntra (ooops..my spelling
> mistake).
>   It could still be made to run about 3 times faster, if the other
> languages are any guide.  Anyone want to help polish this one?
>  Also, two other existing entries have space leaks, as can be seen at
> http://shootout.alioth.debian.org/benchmark.php?test=all&lang=ghc&lang2=ghc

I took a stab at the rev-comp one due to boredom. It's not a space
leak, believe it or not, it's *by design*...

My god, I think someone is consciously trying to sabotage Haskell's reputation!

Instead of reading input line-by-line and doing the computation, it
reads a whole bunch of lines (hundreds of megs worth, apparently) and
only does away with them when a new header appears.

Anyway, I uploaded a dead simple "first-naive-implementation" which is
significantly faster (and more elegant):

complement i = complArr ! i'
             where i' = toUpper i

complArr = array ('A','Z') (self ++ complAssoc)
           where self = az `zip` az
                     az = ['A'..'Z']
complAssoc = [

process header@('>':xs) = putStrLn header
process x = putStrLn (map complement x)

main = do xs <- getContents
               mapM process (lines xs)

Sebastian Sylvan
UIN: 44640862

More information about the Haskell-Cafe mailing list