zend_u_strtod() 400% speed up

From: Date: Fri, 10 Nov 2006 10:34:57 +0000
Subject: zend_u_strtod() 400% speed up
Groups: php.internals 
Request: Send a blank email to internals+get-26456@lists.php.net to get a copy of this message
Hello all. I would like to propose a replacement for current zend_u_strtod() implementation. The patch: http://tony2001.phpclub.net/dev/tmp/u_strtod.diff According to my tests, new implementation is faster in about 40 (forty) times. The simple script below takes ~1 sec to run with the patch and ~40 seconds without. <?php $a = array( "0.1", "1.", "1.0", "23423423.234234", "0.00000E-2", "0.000002E+3", "121231312.1111", "000.11111111", ); $start = microtime(true); for ($i = 0; $i<100000; $i++) { foreach ($a as $d) { $double = (double)$d; } } var_dump(microtime(true) - $start); ?> The only question here is which locale to use for number parsing/formatting. I used "en_US_POSIX" and it doesn't seem to create any new problems, though I'd like to hear your comments. -- Wbr, Antony Dovgal

« previous php.internals (#26456) next »