I have one more comment: PDL and Python run times are both dominated by memory 
accesses.  There are other cases where PDL has large improvements over Python.  
Which one is faster depends on how you are using the language.  For example, 
PDL avoids copying slices of arrays in many cases where Python makes an 
explicit copy.



> On Sep 20, 2020, at 1:15 PM, Craig DeForest <[email protected]> wrote:
> 
> These are pretty comparable operations.  I believe numpy may have implemented 
> lazy processing for constant arrays.  That would save three out of five 
> passes through memory for your test1 operation, which is consistent with the 
> timing results. 
> 
> You might like to compare random arrays rather than constant arrays, for 
> example with the random() function in PDL.
> 
> 
>> On Sep 20, 2020, at 8:11 AM, 钟巍 <[email protected] 
>> <mailto:[email protected]>> wrote:
>> 
>> Hi all, 
>> I am new to PDL. I want to know where is PDL performance.
>> 
>> I test on same virtial machine with lastest version of perl and python in  
>> Ubuntu 20.04 LTS
>> 
>> Perl version:v5.32.0
>> Python version:3.8.5
>> I have a little disappoint about the result:
>> Perl slower a lot than python.
>> 
>> weizhong@weizhong-VirtualBox:~/Git/compare-pdl_numpy$ ./compare.csh
>> 
>> Python test1.py:
>> 0.5u 1.0s 0:01.84 88.0% 0+0k 0+0io 0pf+0w
>> 
>> Perl test1.pl:
>> 1.2u 2.0s 0:05.83 55.5% 0+0k 19064+0io 907pf+0w
>> 
>> Python test1.py:
>> 0.7u 0.7s 0:02.54 60.2% 0+0k 52008+0io 141pf+0w
>> 
>> Perl test1.pl:
>> 1.3u 1.9s 0:05.28 61.3% 0+0k 30432+0io 1005pf+0w
>> 
>> Perl Code(test1.pl):
>> 
>> #!/home/weizhong/tools/perl-5.32.0/perl
>> use PDL;
>> $PDL::BIGPDL = 1;
>> $X = zeroes(1000,500,500);
>> $Y = ones(1000,500,500);
>> $Z1 = $X + $Y;
>> $Z2 = $X / $Y;
>> [download] 
>> <https://www.perlmonks.org/?abspart=1;displaytype=displaycode;part=1;node_id=11121959>
>> Python Code(test1.py):
>> #!/home/weizhong/tools/Python-3.8.5/python
>> import numpy as np
>> X = np.zeros((1000,500,500))
>> Y = np.ones((1000,500,500))
>> Z1 = X+Y
>> Z2 = X/Y
>> [download] 
>> <https://www.perlmonks.org/?abspart=1;displaytype=displaycode;part=2;node_id=11121959>
>> compare.csh:
>> 
>> #!/bin/csh -f
>> echo "Python test1.py:";
>> time ./test1.py
>> echo "Perl test1.pl:";
>> time ./test1.pl
>> echo "Python test1.py:";
>> time ./test1.py
>> echo "Perl test1.pl:";
>> time ./test1.pl
>> 
>> 
>>  
>> _______________________________________________
>> pdl-general mailing list
>> [email protected] <mailto:[email protected]>
>> https://lists.sourceforge.net/lists/listinfo/pdl-general
> 

_______________________________________________
pdl-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pdl-general

Reply via email to