Hello,
I am getting confused now with inplace. The detailed code and times
are shown below.
I am running three tests trying to implement inplace operations
to make the code faster. The summary is:
Test # command time
1: $Re=$Re+1000.; 58 sec
2: $Re.=$Re+1000.; 109 sec
3: $Re->inplace;$Re+1000.; 55 sec
I believe test 3 is doing things really inplace, but its time is almost the
same as test 1, which is the "easy" way. Does this mean
that test 1 is really done inplace? Or maybe test 3 is not done inplace?
I thought the .= operator performed operations inplace, and I would have
thought test 2 was also doing things inplace like test 3. Obviously it is
not. In fact it is taking twice the time to run probably meaning it is
doing the calculations twice. What am I missing here?
Many thanks again,
Xavier
*******************************************
Test 1
-----------------------------------------
$npts=2000;
$niter=1000;
$Re=zeroes(double,$npts,$npts)->xlinvals(-1.5,0.5);
for($j=0;$j<$niter;$j++){
$Re=$Re+1000.;
}
------------------------------------------------
time output:
real 1m0.727s
user 0m22.794s
sys 0m36.667s
******************************************************
Test 2:
---------------------------------------------------
$npts=2000;
$niter=1000;
$Re=zeroes(double,$npts,$npts)->xlinvals(-1.5,0.5);
for($j=0;$j<$niter;$j++){
$Re.=$Re+1000.;
}
------------------------------------------------------
time output:
real 1m53.829s
user 1m11.915s
sys 0m37.040s
*******************************************************
Test 3
-------------------------------------------------------
$npts=2000;
$niter=1000;
$Re=zeroes(double,$npts,$npts)->xlinvals(-1.5,0.5);
for($j=0;$j<$niter;$j++){
$Re->inplace;
$Re+1000.;
}
--------------------------------------------------------
time output:
real 0m33.181s
user 0m32.446s
sys 0m0.190s
_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl