I must be stupid

Joel Reymont <>
Sat Jul 9 20:34:12 CEST 2005


Actually, this looks like a HiPE issue.

1> c(tuple).
{ok,tuple}
2> tuple:populate1([], 2).
[1,2]
3> timer:tc(tuple, test1, [1000000]).
{1281653,
[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27 
|...]}

The above works fine.

Another interesting issue is that creating a list of 1,000,000 items  
in this fashion

populate1(Acc, 0) ->
     Acc;

populate1(Acc, Size) ->
     Acc1 = [Size|Acc],
     populate1(Acc1, Size - 1).

creates just a second without HiPE whereas doing it like this takes I  
don't know how much time (stopped after half an hour or so)

populate(T, 0) ->
     T;

populate(T, Size) ->
     populate(setelement(Size, T, Size), Size - 1).

Is there a simple explanation?

     Thanks, Joel

--
http://wagerlabs.com/uptick






More information about the erlang-questions mailing list