Re: Planning to create Array -> XML extension

From: Date: Thu, 17 Jul 2008 13:48:05 +0000
Subject: Re: Planning to create Array -> XML extension
References: 1 2 3 4 5 6  Groups: php.pecl.dev 
Request: Send a blank email to pecl-dev+get-5636@lists.php.net to get a copy of this message
The speedup of "ob_start + echo" is minor (about 10%). But, if I remove all the output operators, but remain the recurrent array traverse, speedup is about 50% only (on large data, 6000 nodes). So the bottleneck is the PHP recurrent traverse too. Seems in C it could be implemented better. I'll try to use json_encode sources as a basis to do it. On Tue, Jul 15, 2008 at 3:04 PM, Andrey Hristov <php@hristov.com> wrote: > Dmitry Koterov wrote: > >> I think, you will start to notice difference if arrays contain 1000+ >>> >> elements. >> Unfortunately, 100+. I suspect that PHP concatenation operator (".") is >> inefficient because of multiple memory reallocation and copy operations >> performed (there is no Java StringBuffer analog in PHP), so I am planning >> to >> perform thes operations in C memory "doubled-reallocation" algorythm. >> (Direct using of PHP's libxml's appendChild() via PHP calls is even >> slower, >> it's tested.) >> >> And the resulting XML may be about 300-400K (bad, but can't do anything >> with >> that, it's the legacy architecture issue). These 300K are parsed by >> libxslt >> in 2-3ms (very fast!), but generated from arrays for about 100-200ms in >> pure >> PHP (very slow). It's a real problem... >> >> There is a php extension to generate JSON and it should be no problem to >>> >> go from JSON to XML in Java. >> The language is PHP, so I don't want to use Java. The processor is >> http://php.net/xsl >> >> > Have you tried with recursive algorithm that instead of creating a string > does output the text. Just prevent the output by enabling the output > buffering. At the end just read the output buffer and clean it. Not sure if > the ob subsystem if more efficient, this is just a hint to try something > before starting C coding. Otherwise, you might implement StringBuffer class > and still do the conversion in PHP userland. The Buffer will insternally use > smart_str for example. Won't be hard to implement. > > Andrey > > -- > PECL development discussion Mailing List (http://pecl.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >

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