R
Rainer Weikusat
I recently read the 'Lambda: The ultimate GOTO' paper published by
Steele/ Sussman in 1977[*]. While I mostly consider this 'an
entertaining rant', the idea that The Absolutely Dreadful Function
Call Overhead[tm] is rather an urban legend people keep telling each
other seemed plausible to me. Of course, just as in any other
language, it is well-known that "subroutine [...] calls are horribly
slow" in perl[**]. Because I wanted to know what precisely 'horribly
slow' means, I wrote the following small test program:
------------
use Benchmark;
sub perl_dummy
{
return 1;
}
timethese(-1,
{
perl_dummy => sub { perl_dummy(); },
empty => sub { return 1; }});
------------
The results I got from that (averaging four runs and substracting the
average 'empty' speed from the average 'perl_dummy' speed) was that a
pure subroutine call alone takes about 1.36E-7 seconds for perl 5.10.1
running on a 3.2Ghz Core i3 computer. When using 1,2,3 as argument
list for perl_dummy, the time needed to call it (calculated in the
same way) was about 1.74E-7s. In line with the thesis from the paper,
I think that people are rather 'horrified' by function calls because
they are function calls (... and everyone knows that ...) than by the
prospect of runing some code which needs less than 0.0000002 to
execute.
[*]
http://repository.readscheme.org/ftp/papers/ai-lab-pubs/AIM-443.pdf
[**]
http://c2.com/cgi/wiki?WhyHatePerl
Steele/ Sussman in 1977[*]. While I mostly consider this 'an
entertaining rant', the idea that The Absolutely Dreadful Function
Call Overhead[tm] is rather an urban legend people keep telling each
other seemed plausible to me. Of course, just as in any other
language, it is well-known that "subroutine [...] calls are horribly
slow" in perl[**]. Because I wanted to know what precisely 'horribly
slow' means, I wrote the following small test program:
------------
use Benchmark;
sub perl_dummy
{
return 1;
}
timethese(-1,
{
perl_dummy => sub { perl_dummy(); },
empty => sub { return 1; }});
------------
The results I got from that (averaging four runs and substracting the
average 'empty' speed from the average 'perl_dummy' speed) was that a
pure subroutine call alone takes about 1.36E-7 seconds for perl 5.10.1
running on a 3.2Ghz Core i3 computer. When using 1,2,3 as argument
list for perl_dummy, the time needed to call it (calculated in the
same way) was about 1.74E-7s. In line with the thesis from the paper,
I think that people are rather 'horrified' by function calls because
they are function calls (... and everyone knows that ...) than by the
prospect of runing some code which needs less than 0.0000002 to
execute.
[*]
http://repository.readscheme.org/ftp/papers/ai-lab-pubs/AIM-443.pdf
[**]
http://c2.com/cgi/wiki?WhyHatePerl