marm Posted May 4, 2007 Share Posted May 4, 2007 Where could I find a web which states the speeds of php functions. I'm particularly interested in the speeds of hashes, checksums etc. Quote Link to comment Share on other sites More sharing options...
taith Posted May 4, 2007 Share Posted May 4, 2007 $time=microtime(); #use function echo 'that took '.microtime()-$time.' seconds'; Quote Link to comment Share on other sites More sharing options...
DaveEverFade Posted May 4, 2007 Share Posted May 4, 2007 If you can't find a webpage you can do it yourself using microtime() ie $time_start = microtime(true); //Do some stuff... $time_end = microtime(true); $time = $time_end - $time_start; echo "Stuff took $time seconds"; (ps - this was yoinked off php.net) Quote Link to comment Share on other sites More sharing options...
marm Posted May 4, 2007 Author Share Posted May 4, 2007 Ok, but if you those scripts, the results vary: you press "refresh" in your browser and you can get a totally different answer. And the order in which you use the functions inside those scripts also make the results vary. How can I get an "unbiased" result? Quote Link to comment Share on other sites More sharing options...
Barand Posted May 4, 2007 Share Posted May 4, 2007 I usually time over 1000 iterations and get an average Quote Link to comment Share on other sites More sharing options...
marm Posted May 4, 2007 Author Share Posted May 4, 2007 Its interesting to point out that: bin2hex(mhash(MHASH_SHA1("whatever"))); takes nearly double the time than: sha1("whatever"); Can other hashes be "built into php" like sha1 is? Quote Link to comment Share on other sites More sharing options...
taith Posted May 4, 2007 Share Posted May 4, 2007 bin2hex(md5('adsf',TRUE)); #takes 1-2 times faster then md5 alone Quote Link to comment Share on other sites More sharing options...
marm Posted May 4, 2007 Author Share Posted May 4, 2007 hash('md5', 'string'); returns: Fatal error: Call to undefined function: hash() bin2hex(md5('string', TRUE)); returns: Warning: Wrong parameter count for md5() (these errors happen in PHP4 since they were added in PHP5) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.