Le vendredi 02 mars 2007 à 09:01 +0000, Xavier Calbet a écrit :
>
> 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 still don't have a good feel for inplace myself
but I think using += rather than .= would do
the same as test 3. Here is the benchmark I
ran:
perldl> timethese(100, {
..({ > 'test1' => '$Re = $Re + 1000',
..({ > 'test2' => '$Re.= $Re + 1000',
..({ > 'test2a'=> '$Re+= 1000',
..({ > 'test3' => '$Re->inplace; $Re + 1000'
..({ > })
Benchmark: timing 100 iterations of test1, test2, test2a, test3...
test1: 6 wallclock secs ( 3.56 usr + 2.33 sys = 5.89 CPU) @ 16.98/s
(n=100)
test2: 9 wallclock secs ( 6.86 usr + 2.22 sys = 9.08 CPU) @ 11.02/s
(n=100)
test2a: 3 wallclock secs ( 3.27 usr + 0.00 sys = 3.27 CPU) @ 30.62/s
(n=100)
test3: 4 wallclock secs ( 3.31 usr + 0.02 sys = 3.33 CPU) @ 30.04/s
(n=100)
_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl