[erlang-questions] list comprehensions speed

Oleg <>
Tue Feb 25 18:06:07 CET 2014


On Tue, Feb 25, 2014 at 03:30:13PM +0100, Jesper Louis Andersen wrote:
> On Tue, Feb 25, 2014 at 2:08 PM, Oleg <> wrote:
> 
> >   Hello.
> >
> 
> Hi Oleg!
> 
> 
> >
> > I'm erlang newbie. Don't beat me, please :-), if this question is obvious.
> >
> > I have a list of key-value pairs:
> >
> > A=[{"name1", 1}, {"name2", 77}, {"name3", 33}, {"name4", 234}].
> >
> > What is faster:
> >
> >
> The way you can figure this out is by following three basic rules:
> 
> 1. use timer:tc/1 to measure the execution time.
> 2. Remember to do it in a module which is compiled. The shell interprets.
> 3. Remember to only measure what you want to measure!
> 
> https://gist.github.com/jlouis/9209794

Wow. lists:keyfind/3 much faster!

Thank you all for answers.



More information about the erlang-questions mailing list