[erlang-questions] list comprehensions speed

Motiejus Jakštys <>
Tue Feb 25 15:24:35 CET 2014


2014.02.25 14:08, Oleg rašė:
>   Hello.
> 
> I'm erlang newbie. Don't beat me, please :-), if this question is obvious.

Hi,

these questions are best to just test. It's simple:

> timer:tc(fun million_list_comprehensions/0).
> timer:tc(fun million_get_values/0).

You will get a 2-tuple. First element in that tuple will give function
execution time in microseconds.

Things to have in mind:
1. Put it to module and compile it, do not run from the shell.
2. Make sure to make a loop so it runs more than 10ms (so it actually
shows something).
3. Run more than one test for each clause.

Have fun!

Motiejus



More information about the erlang-questions mailing list