16 May 23:59
Re: Re: Write Haskell as fast as C.
From: Don Stewart <dons <at> galois.com>
Subject: Re: Re: Write Haskell as fast as C.
Newsgroups: gmane.comp.lang.haskell.cafe
Date: 2008-05-16 21:59:33 GMT
Subject: Re: Re: Write Haskell as fast as C.
Newsgroups: gmane.comp.lang.haskell.cafe
Date: 2008-05-16 21:59:33 GMT
ketil:
> Andrew Coppin <andrewcoppin <at> btinternet.com> writes:
>
> > I'm more worried about what happens in less trivial examples. [Let's
> > face it, who wants to compute the sum of the numbers from 1 to N?]
>
> Inspired by Don's blog post, and coincidentally working on a program
> where profiling points to one particular, short function as
> responsible for 60% of the work, I thought this would be a good time
> to look into core and reveal the deep secrets of my code. This is the
> function:
>
> > mkAnn :: ByteString -> Annotation
> > mkAnn = pick . B.words
> > where pick (_db:up:rest) = pick' up $ getGo rest
> > pick' up' (go:_:ev:_) = Ann (B.copy up') (read $ B.unpack go) (read $ B.unpack ev)
> > getGo = dropWhile (not . B.isPrefixOf (pack "GO:"))
>
read $ B.unpack go
Looks suspicious. You're unpacking to lists.
ByteString performance rule 1: don't unpack to lists.
-- Don
RSS Feed