The Computer Language Shootout

Kenneth Johansson <>
Fri Mar 17 12:10:32 CET 2006


On Fri, 2006-03-17 at 10:57 +0100, Ulf Wiger (AL/EAB) wrote:
> One obvious first optimization would be to
> not use string:str(Line, ">THREE Homo sapiens frequency"),
> but rather to check whether the line actually starts
> with ">THREE", thus:
> 
> seek_three() ->
>     case io:get_line('') of
>        ">THREE" ++ _ -> found;
>        eof -> erlang:error(eof);
>        _ -> seek_three()
>     end.
> 
> This tiny change alone gives a 18% speedup
> on my machine.

Really I tested and could not notice any change and to me that is not so
strange since I can't imagine why having a longer string could slow us
down since it will only match the first character three times and two
out of them it will fail on the second char. only once will it do the
whole string and that extra work will hardly be possible to measure.



> Regards,
> Ulf W
> 
> > -----Original Message-----
> > From:  
> > [mailto:] On Behalf Of 
> > Kenneth Johansson
> > Sent: den 17 mars 2006 04:23
> > To: 
> > Subject: The Computer Language Shootout
> > 
> > http://shootout.alioth.debian.org/gp4/benchmark.php?test=knucl
> > eotide&lang=all
> > 
> > I did an implementation in erlang for the knucleotide.  
> > 
> > And while the code is much shorter than C and fortran it's 
> > larger than ruby and python. But since this is my first real 
> > try at erlang I'm sure someone here can do significant improvement.
> > 
> > Also the speed is a problem it's on my computer 8 times 
> > slower than the python version.
> > 
> > 




More information about the erlang-questions mailing list