note 105541 added to function.strncmp

From: Date: Thu, 25 Aug 2011 20:23:37 +0000
Subject: note 105541 added to function.strncmp
Groups: php.notes 
Request: Send a blank email to php-notes+get-182737@lists.php.net to get a copy of this message
@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. ---- Server IP: 69.147.83.197 Probable Submitter: 75.147.140.118 ---- Manual Page -- http://www.php.net/manual/en/function.strncmp.php Edit -- https://master.php.net/note/edit/105541 Del: integrated -- https://master.php.net/note/delete/105541/integrated Del: useless -- https://master.php.net/note/delete/105541/useless Del: bad code -- https://master.php.net/note/delete/105541/bad+code Del: spam -- https://master.php.net/note/delete/105541/spam Del: non-english -- https://master.php.net/note/delete/105541/non-english Del: in docs -- https://master.php.net/note/delete/105541/in+docs Del: other reasons-- https://master.php.net/note/delete/105541 Reject -- https://master.php.net/note/reject/105541 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#182737) next »