`lists:reverse/1` vs. `lists:reverse/2` performance
TD5 opened this issue · 1 comments
TD5 commented
Describe the bug
lists:reverse(List,[])
is ~50% faster than lists:reverse(List)
for big lists, and about the same for tiny lists, according to my benchmarks.
Unlike lists:reverse/1
, lists:reverse/2
is implemented in a BIF, and is documented as follows:
Returns a list with the elements in List1 in reverse order, with tail Tail
appended.Example:
$ lists:reverse([1, 2, 3, 4], [a, b, c]).
[4,3,2,1,a,b,c]
Expected behaviour
Comparable performance between the two.
TD5 commented
Hmm, after rerunning my benchmarks with more samples, I can't reproduce this, so I guess it was just noise.