[erlang-questions] Anonymous functions and performance

Robert Virding robert.virding@REDACTED
Wed Nov 2 10:41:48 CET 2011


Also making just one call in the test is so fast that the timing will be dominated by setting up the test and what is done inside the fun. In your case you should call the funs "many" times with a really trivial list. I would not expect there to be much different but I haven't measured. 

Robert 

----- Original Message -----

> You are right about the test, i didn't consider it.

> On Tue, Nov 1, 2011 at 6:38 PM, Filipe David Manana <
> fdmanana@REDACTED > wrote:

> > 33> F1 = fun lists:sort/1.
> 
> > > #Fun<lists.sort.1>
> 
> > > 34> F = fun(A)-> lists:sort(A) end.
> 
> > > #Fun<erl_eval. 6.80247286 >
> 
> > > 35> F1 = fun lists:sort/1.
> 
> > > #Fun<lists.sort.1>
> 
> > > 36> timer:tc(erlang, apply, [F, [[2,3,5,1,10,9,8]]]).
> 
> > > {11,[1,2,3,5,8,9,10]}
> 
> > > 37> timer:tc(erlang, apply, [F1, [[2,3,5,1,10,9,8]]]).
> 
> > > {4,[1,2,3,5,8,9,10]}
> 
> --
> Best Regards,
> - Ahmed Omar
> http://nl.linkedin.com/in/adiaa
> Follow me on twitter
> @spawn_think

> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20111102/5be110a5/attachment.htm>


More information about the erlang-questions mailing list