Re: zend_u_strtod() 400% speed up
| From: | Antony Dovgal | Date: | Thu, 16 Nov 2006 19:22:20 +0000 |
| Subject: | Re: zend_u_strtod() 400% speed up | ||
| References: | 1 2 3 4 5 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-26650@lists.php.net to get a copy of this message | ||
On 11/16/2006 08:59 PM, Andrei Zmievski wrote:
Matt and Antony, I this we should go with Matt's patch, since we care only about ASCII characters in strings.Agree. I'm going to spend some time on this, re-test it once again and commit it after that.
On Nov 13, 2006, at 4:46 AM, Matt Wilmas wrote:-- Wbr, Antony DovgalHi Antony, ----- Original Message ----- From: "Antony Dovgal" Sent: Friday, November 10, 2006On 11/10/2006 02:14 PM, Matt Wilmas wrote:secondsHi Antony, ----- Original Message ----- From: "Antony Dovgal" Sent: Friday, November 10, 2006Hello 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 ~40seewithout. Cool. :-) I'd just been thinking about zend_u_strtod() again -- if younumbers...my thread asking Andrei about the Unicode characters allowed asjustI changed the function back in the summer to be about 8x faster by converting FROM Unicode and using the regular zend_strtod(), but it wasHmm, I don't understand how mine was faster if yours was 40x faster than the current version, as when I tested mine, it was only ~8x. :-/ Well anyway, as I mentioned in my first reply, I had another idea since I learned (from README.UNICODE and Andrei) that only ASCII digits are allowed in Unicode. I just put this together: http://realplain.com/php/zend_u_strtod.c I didn't test it (or even try to compile), but you get the idea -- "manually" copying the relevant Unicode chars to a char * (am I doing that right?). I've got the "char buf[64]" there, assuming it's more efficient than using emalloc() (?), when the number will fit. I didn't know what size to make it, just whatever catches the vast majority of cases... I'd really like to see a faster version implemented soon. :-) Matta quick hack, so maybe better that it wasn't applied! http://realplain.com/php/zend_u_strtod.diffHmm.. Actually, your version seems to be slightly faster (~15%) than mine and there are several advantages, like no formatter is required, avoiding parsing non-numeric strings and less TSRMLS_FETCH() calls, which leads to even better results on non-numeric strings. Also, it looks like a good idea to use zend_strtod() in both native and unicode modes.