The Computer Language Shootout
Ulf Wiger (AL/EAB)
ulf.wiger@REDACTED
Sat Mar 18 12:05:53 CET 2006
Here's a version that uses ets instead of dict.
In order to make sure the ets tables were removed
in an orderly fashion, I made a small wrapper
function.
new_hash(F) ->
T = ets:new(hash, [set]),
Res = F(T),
ets:delete(T),
Res.
main() ->
Seq = dna_seq(),
lists:foreach(fun(H) ->
new_hash(fun(T) ->
printf(gen_freq(T,Seq,H))
end)
end, [1,2]),
lists:foreach(fun(H) -> write_count(Seq,H) end,
[<<"GGT">>,<<"GGTA">>,<<"GGTATT">>,<<"GGTATTTTAATT">>,<<"GGTATTTTAATTTAT
AGT">>]),
halt(0).
Running time on my machine went down from
3.74 sec to 1.47. A 70% improvement (overall this time. ;)
The ratio may be different on hipe. I haven't checked.
Regards,
Ulf W
> -----Original Message-----
> From: owner-erlang-questions@REDACTED
> [mailto:owner-erlang-questions@REDACTED] On Behalf Of
> Kenneth Johansson
> Sent: den 18 mars 2006 01:45
> To: Vlad Dumitrescu
> Cc: erlang-questions@REDACTED
> Subject: RE: The Computer Language Shootout
>
> On Fri, 2006-03-17 at 11:48 +0100, Vlad Dumitrescu wrote:
> > Hi,
> > Also, an even better result (~half the time) can be
> obtained by using
> > binaries instead of lists:
>
> Nice I copied that and did some small line reducing changes
> If no one has any other suggestions I submit this version
> some time next week.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20060318/05e4c47f/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: knucleotide.erl
Type: application/octet-stream
Size: 2846 bytes
Desc: not available
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20060318/05e4c47f/attachment.obj>
More information about the erlang-questions
mailing list