in reply to Re^3: Performance, Abstraction and HOP
in thread Performance, Abstraction and HOP
So if Perl's function calls are "too slow" (whatever that means, and nobody in this thread has suggested any relevant meaning)
~/perl$ cat func_test.pl #!/usr/bin/perl #sum of number between 1 and 1,000,000 $n = 1_000_000; print addup($n, 0); sub addup { return $_[1] if !$_[0]; return addup($_[0]-1,$_[1]+$_[0]); } ~/perl$ cat loop_test.pl #!/usr/bin/perl #sum of number between 1 and 1,000,000 $n = 1_000_000; $sum = 0; $sum += $n-- while($n); ~/perl$ time ./func_test.pl 500000500000 real 0m4.025s user 0m3.568s sys 0m0.455s ~/perl$ time loop_test.pl real 0m0.390s user 0m0.388s sys 0m0.001s
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Performance, Abstraction and HOP
by runrig (Abbot) on Sep 14, 2005 at 22:21 UTC |