Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:26538 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 7512 invoked by uid 1010); 13 Nov 2006 12:46:58 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 7497 invoked from network); 13 Nov 2006 12:46:58 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 Nov 2006 12:46:58 -0000 Authentication-Results: pb1.pair.com header.from=php_lists@realplain.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=php_lists@realplain.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain realplain.com from 69.179.208.43 cause and error) X-PHP-List-Original-Sender: php_lists@realplain.com X-Host-Fingerprint: 69.179.208.43 msa3-mx.centurytel.net Linux 2.4/2.6 Received: from [69.179.208.43] ([69.179.208.43:44962] helo=msa3-mx.centurytel.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E3/99-40419-F3968554 for ; Mon, 13 Nov 2006 07:46:56 -0500 Received: from pc1 (d37-19.rt-bras.wnvl.centurytel.net [69.179.164.19]) by msa3-mx.centurytel.net (8.13.6/8.13.6) with SMTP id kADCknYN003315; Mon, 13 Nov 2006 06:46:49 -0600 Message-ID: <011b01c70721$ca0ec7f0$0201a8c0@pc1> To: "php-dev" , "Antony Dovgal" , "Andrei Zmievski" References: <455455D1.3020706@zend.com> <017f01c704b9$5e07f870$0201a8c0@pc1> <45546EDB.2020400@zend.com> Date: Mon, 13 Nov 2006 06:46:50 -0600 MIME-Version: 1.0 Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1807 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1807 Subject: Re: [PHP-DEV] zend_u_strtod() 400% speed up From: php_lists@realplain.com ("Matt Wilmas") Hi Antony, ----- Original Message ----- From: "Antony Dovgal" Sent: Friday, November 10, 2006 > On 11/10/2006 02:14 PM, Matt Wilmas wrote: > > Hi Antony, > > > > ----- Original Message ----- > > From: "Antony Dovgal" > > Sent: Friday, November 10, 2006 > > > >> 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. > > > > Cool. :-) I'd just been thinking about zend_u_strtod() again -- if you see > > my thread asking Andrei about the Unicode characters allowed as numbers... > > I changed the function back in the summer to be about 8x faster by > > converting FROM Unicode and using the regular zend_strtod(), but it was just > > a quick hack, so maybe better that it wasn't applied! > > http://realplain.com/php/zend_u_strtod.diff > > Hmm.. 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. Hmm, 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. :-) Matt