Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:73262 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 24001 invoked from network); 18 Mar 2014 09:09:44 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Mar 2014 09:09:44 -0000 Authentication-Results: pb1.pair.com header.from=ivan.enderlin@hoa-project.net; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=ivan.enderlin@hoa-project.net; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain hoa-project.net from 95.130.10.56 cause and error) X-PHP-List-Original-Sender: ivan.enderlin@hoa-project.net X-Host-Fingerprint: 95.130.10.56 host1.ip6-networks.net Received: from [95.130.10.56] ([95.130.10.56:47460] helo=host1.ip6-networks.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 34/00-23742-45D08235 for ; Tue, 18 Mar 2014 04:09:41 -0500 Received: from Hwhost2.local (184-175.106-92.cust.bluewin.ch [92.106.175.184]) by host1.ip6-networks.net (Postfix) with ESMTPSA id B621D60821 for ; Tue, 18 Mar 2014 10:09:37 +0100 (CET) Message-ID: <53280D52.5040209@hoa-project.net> Date: Tue, 18 Mar 2014 10:09:38 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:29.0) Gecko/20100101 Thunderbird/29.0a2 MIME-Version: 1.0 To: internals@lists.php.net References: In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] New JSON parser From: ivan.enderlin@hoa-project.net ("Ivan Enderlin @ Hoa") On 13/03/2014 20:48, Jakub Zelenka wrote: > Hi, Hi Jakub, > I have create a new JSON parser using conditional re2c and pure pull Bi= son > parser. It's a native UTF-8 parser licensed under PHP license (it can b= e > used for Evil though :) ). The extension is available at > > https://github.com/bukka/php-jsond Very nice work, thanks! > [snip] > > I need to do more testing before creating RFC for replacing the current= > parser. There is still space for further improvements. If anyone has an= y > ideas, please let me know. Or if you could test it, that would be great= > too! ;) For my PhD thesis in the automatic testing domain, I have created some=20 grammar-based testing algorithms, based on our dedicated LL(k) compiler=20 compiler (with its dedicated grammar description language called PP).=20 Please, see the article [1] (along with the presentation [2] and all the = details [3] about the article and the conference) and also the tool [4]=20 (called Hoa\Compiler). In this article, my experimentation consisted to=20 generate a lot of JSON strings (based on the JSON grammar [5] written in = PP) and compared them against the JSON parsers of Gecko and PHP. Now I=20 re-play this experimentation but I compare all the generated data with=20 ext/json and ext/jsond to see if there is no potential regression. Also, = I test it with a bounded exhaustive algorithm: it means we generate all=20 possible JSON strings up to a given size (the unit is the number of=20 tokens in a sequence, so `{`, `true` or `foo` are tokens). Note that we=20 have two ther algorithms: uniform random generation and coverage-based=20 generation. I have created a little repository to share my work [6]. I have=20 generated all sequences up to 15 tokens, which represents 356'327 data=20 and no one has failed. Congrats! Just for the record, a good test is a test that fails. Here, I have=20 detected no regeression, and because I have previously compared the=20 ext/json with the JSON parser from Gecko, we can consider your=20 implementation as =E2=80=9Csafe=E2=80=9D. This is my little contribution of the morning :-). You can use this work = to generate data in a static file and use them to compare the memory and = CPU usage between ext/json and ext/jsond also. Best regards. [1] http://hoa-project.net/Literature/Research/Amost12.html [2] http://keynote.hoa-project.net/Amost12/EDGB12.pdf [3] http://hoa-project.net/Event/Amost12.html [4] https://github.com/hoaproject/Compiler [5] https://github.com/hoaproject/Json/blob/master/Grammar.pp [6] https://github.com/Hywan/jsond-test --=20 Ivan Enderlin Developer of Hoa http://hoa-project.net/ PhD. student at DISC/Femto-ST (Vesontio) and INRIA (Cassis) http://disc.univ-fcomte.fr/ and http://www.inria.fr/ Member of HTML and WebApps Working Group of W3C http://w3.org/