
13 May
2009
13 May
'09
5:05 p.m.
On Wed, May 13, 2009 at 6:50 PM, Steven Watanabe <watanabesj@gmail.com> wrote:
I'm not absolutely sure about this, but from the assembler it looks like the call to strlen is being pulled out of the loop.
You're right, I added __attribute__((noinline)) to the test_strlen and test_sentinel functions and I also added -DNDEBUG this time around now I get the following times: enter text length: 8 strlen: 0.05 2468358720 sentinel: 0.04 2468358720 enter text length: 512 strlen: 2.46 3054888576 sentinel: 2.17 3054888576 enter text length: 8096 strlen: 38.58 2775800256 sentinel: 34.09 2775800256 which shows that the sentinel version is indeed faster. It's comforting to know that programmer intuition works after all!