Re:The Greatest Bug of All
by tptacek on Tuesday July 08, 2008 @06:49PM
(#240471)
By the way, you asked me to time getpid against "a function that returns a constant integer". Obviously that's a silly comparison (getpid isn't really returning a constant; it's a vectored call and it has to pull the PID out of a structure offset from %%fs). But here's a fairer fight: getpid vs. a trivial LFSR:
s = (s >> 1) ^ (-(s & 1) & 0xd0000001);
I also timed it the way you asked, with wall clock time over 100M iterations (10M runs too fast to time). Surprising even me, getpid wins by almost a full second.
Got another challenge for me to write code for?