note 105541 deleted from function.strncmp by danbrown

From: Date: Thu, 25 Aug 2011 20:52:58 +0000
Subject: note 105541 deleted from function.strncmp by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-182740@lists.php.net to get a copy of this message
Note Submitter: dharkness at gmail dot com ---- @bobvin - When I run your script as written I get the results you summarized. Stranger, strpos() with "xyz" is faster than with "abc". This is backwards from my expectation since "xyz" will require scanning the whole string. I see the same thing for "123": it's faster than both. Perhaps strpos() is scanning from the end of the string? However, if I reverse the loops so that strpos() is timed after strncmp() , strncmp() is faster than "abc" for strpos() and nearly identical to it for "xyz" and "123". Also, "abc" with strpos() is 30% slower than "xyz" and "123". In short, performing micro-benchmarks is always tricky and rarely repeatable. I see significant variations when running this script multiple times.

« previous php.notes (#182740) next »