Re: Proposal for a new extension BBCode Parser

From: Date: Fri, 09 Feb 2007 00:21:31 +0000
Subject: Re: Proposal for a new extension BBCode Parser
References: 1 2  Groups: php.pecl.dev 
Request: Send a blank email to pecl-dev+get-4488@lists.php.net to get a copy of this message
Hi all, I've worked on the announced extension and made some changes, i don't know if it is useful to put them here but it's best to say too much than too few (IMHO) therefore, here are the changes i've done. Some Updates to the features of the extension * Added prototype and in-line documentation to php_bbcode.c * Child Tags Limitations * Limit one tag to be under some other tags. * Ability to remove direct CDATA from a tag. * Added Special empty Tag for Root Element (restrict Root Child). Child tags limitation example: * Restrict [code] tag to contain only "" children it will disable nesting. * Restrict [url] tag to contain only "b,color,u,size,i" it will limit the parsing to those tags. * Permit [b] tag to contain anything but block level element by setting child_list at "!right,left,center,just,img" * Permit [right tag to contain anything by setting childs at "all" Limit one tag to be under some other tags. * Restrict [highlight] tag to be children of "code,pre" tag this will permit to ignore any highlight tag found not as direct child of highlight. Changes to the parsing library: * Reference pass of the bbcode_array - performance increases - added Just In Time bbcode_array preparation minimize performance loss when unused bbcode is created. Some Basic Benchmarking show that it outperforms non validated basic preg_replace bbcode replacement. Note on benchmark: each BBCode "with Init" time is done with full init of the bbcode resource, this is visibly not done by preg_match, therefore "only" the second call must be taken in account (or i must find a way to cache). The script used for this benchmark was test.php included in the archive on http://www.projet-ivy.net/bbcode.tar.bz2 (archive has been upgraded) -------------------------------- Benchmark Done: == Test on 10 byte text == Preg_replace-Time [9 elements] :0.00044894218444824s Preg_replace Second Call -Time [9 elements] :2.6941299438477E-05s BBcode-Time With Init [35 elements] :0.00030398368835449s BBCode Second Call [35 elements] :1.4066696166992E-05s BBcode-Time With Init No Callback [35 elements] :0.00028610229492188s BBCode No Callback Second Call [35 elements] :1.4066696166992E-05s == Test on 100 byte text == Preg_replace-Time [9 elements] :2.5033950805664E-05s Preg_replace Second Call -Time [9 elements] :2.4080276489258E-05s BBcode-Time With Init [35 elements] :0.00044703483581543s BBCode Second Call [35 elements] :1.3828277587891E-05s BBcode-Time With Init No Callback [35 elements] :0.00028705596923828s BBCode No Callback Second Call [35 elements] :1.3828277587891E-05s == Test on 1000 byte text == Preg_replace-Time [9 elements] :2.598762512207E-05s Preg_replace Second Call -Time [9 elements] :2.288818359375E-05s BBcode-Time With Init [35 elements] :0.00030183792114258s BBCode Second Call [35 elements] :1.4066696166992E-05s BBcode-Time With Init No Callback [35 elements] :0.00029182434082031s BBCode No Callback Second Call [35 elements] :1.2874603271484E-05s == Test on 10000 byte text == Preg_replace-Time [9 elements] :2.5033950805664E-05s Preg_replace Second Call -Time [9 elements] :2.288818359375E-05s BBcode-Time With Init [35 elements] :0.00030016899108887s BBCode Second Call [35 elements] :1.4066696166992E-05s BBcode-Time With Init No Callback [35 elements] :0.00030303001403809s BBCode No Callback Second Call [35 elements] :1.3113021850586E-05s == Test on 93965 byte text == Preg_replace-Time [9 elements] :2.5033950805664E-05s Preg_replace Second Call -Time [9 elements] :2.4080276489258E-05s BBcode-Time With Init [35 elements] :0.00029993057250977s BBCode Second Call [35 elements] :1.2874603271484E-05s BBcode-Time With Init No Callback [35 elements] :0.00029897689819336s BBCode No Callback Second Call [35 elements] :1.4066696166992E-05s

« previous php.pecl.dev (#4488) next »