Again $table function, speed/functionality improved



On Aug 18, 2009, at 8:14 PM, Leo Butler wrote:
>
> I don't believe so. I ran similar tests with 5.18.1 and gcl2.6.8pre  
> and
> table and create_list have essentially the same speed, with  
> create_list
> slightly faster. This is also true with clisp.
>
> (%i3) compile_file("/home/lbutler/lisp/table.lisp");
> (%i4) table(1,[3]);
> Evaluation took 0.0000 seconds (0.0000 elapsed)
> (%o4) [1,1,1]
> (%i5) for i:1 thru 10 do table(random(1.0),[10^5])$
> Evaluation took 17.2000 seconds (17.2300 elapsed)
> (%i6) for i:1 thru 10 do create_list(random(1.0),i,1,10^5)$
> Evaluation took 16.8800 seconds (16.9000 elapsed)
> (%i7) build_info();
>
> Maxima version: 5.18.1
> Maxima build date: 13:2 4/20/2009
> host type: i686-pc-linux-gnu
> lisp-implementation-type: GNU Common Lisp (GCL)
> lisp-implementation-version: GCL 2.6.8
>
> That's my 2p. Leo.

Are you using the latest 'version' of table.lisp (it used to be  
slower in former 'versions')? Again, my results differ - table is  
considerably faster on my machine. Which is not surprising if you  
inspect source code of $table and $create_list
table(random(1.0),[10^5])$
effectivly calls 'meval' on 'random(1.0)' in a 'dotimes' loop 10^5  
times, while $create_list binds variable values and so on... It  
cannot be possibly faster, since the [10^5] iterator is basicly a  
simple loop which pushes results in a list, while $create_list always  
binds the variables (using the unsafe 'setf') and so on...

Try with the version from the phpBB... I'd be REALLY surprised if it  
ran slower. I get
(%i3) for i:1 thru 10 do table(random(1.0),[10^5])$
Evaluation took 3.7080 seconds (3.8500 elapsed) using 283.257 MB.
(%i4)  for i:1 thru 10 do create_list(random(1.0),i,1,10^5)$
Evaluation took 5.5760 seconds (5.6220 elapsed) using 298.484 MB.


Based on inspection of source code of both $table and $create_list,  
$table should be considerably faster for such cases on all Lisp  
implementations... Even when $table binds a variable it should be  
faster (though the difference is smaller):
(%i5) for i:1 thru 10 do table(random(1.0),[i,10^5])$
Evaluation took 5.2640 seconds (5.4100 elapsed) using 283.208 MB.
(%i6)  for i:1 thru 10 do create_list(random(1.0),i,1,10^5)$
Evaluation took 5.5370 seconds (5.5730 elapsed) using 298.485 MB.
...

Please try with the table.lisp from the phpBB - it must be faster. I  
understand you don't believe untill you see it with your own eyes :)

Regards,
Ziga