[erlang-questions] Coming Back (maybe improving lists:reverse/1)
Richard A. O'Keefe
ok@REDACTED
Fri Oct 9 03:22:38 CEST 2015
On 9/10/2015, at 2:24 am, Ivan Carmenates Garcia <co7eb@REDACTED> wrote:
>
> Yes I mean the C implementation, because if you do 1 millon of repetances of
> lists:length/1 in Erlang and the same for lists:reverse/1 for the same list,
> lists:length takes 16 milliseconds in my pc and lists:reverse takes 64
> milliseconds.
This is pretty meaningless. What is the length of the lists?
Here are some results of mine, obtained just now:
% |L| = 100 |L| = 1000
% length/1 in Erlang 0.26 usec 2.56 usec
% reverse/1 in Erlang 0.44 usec 3.32 usec
% length/1 built-in 0.13 usec 1.21 usec
% lists:reverse/1 0.36 usec 3.44 usec
The "in Erlang" entries were obtained with code manually
unrolled by a factor of 4.
The question was "four times *what*", and it appears to be
that the answer was "CPU time". I actually get a little under
a factor of 3 there, but this probably depends on the version
and the machine and a lot of other things.
More information about the erlang-questions
mailing list