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. Link to comment https://forums.phpfreaks.com/topic/49978-check-function-speeds/ 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'; Link to comment https://forums.phpfreaks.com/topic/49978-check-function-speeds/#findComment-245343 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) Link to comment https://forums.phpfreaks.com/topic/49978-check-function-speeds/#findComment-245346 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? Link to comment https://forums.phpfreaks.com/topic/49978-check-function-speeds/#findComment-245349 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 Link to comment https://forums.phpfreaks.com/topic/49978-check-function-speeds/#findComment-245356 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? Link to comment https://forums.phpfreaks.com/topic/49978-check-function-speeds/#findComment-245383 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 Link to comment https://forums.phpfreaks.com/topic/49978-check-function-speeds/#findComment-245386 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) Link to comment https://forums.phpfreaks.com/topic/49978-check-function-speeds/#findComment-245405 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.