pacoxeon / phpsvg

Automatically exported from code.google.com/p/phpsvg
0 stars 0 forks source link

Performance issues with XmlElement::prettyXML() when using images #6

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I'm using phpsvg for a project at my work (http://hacklab.com.br). It is 
helping us a lot. So first of all thanks for publishing this library.

I just have found one minor performance issue in XmlElement::prettyXML(). When 
trying to output a SVG with images using SVGDocument::asXML() the process is 
really slow because of the several calls to preg_match() performed in 
XmlElement::prettyXML().

From what I could understand XmlElement::prettyXML() is used only to make the 
printed XML prettier. Is that correct? If so, what about a new parameter to 
SVGDocument::asXML() to control whether the XML should be formated or not? I'm 
attaching a patch with this proposed change.

For the moment, to overcome the performance problem I'm creating a new class 
that extends SVGdocument and overriding XmlElement::prettyXML() in it. I 
haven't investigate how to improve the performance in XmlElement::prettyXML().

More information below:

What steps will reproduce the problem?
$svg = SVGDocument::getInstance();
$svg->addShape(SVGImage::getInstance(0, 0, 'myImage', 'pathToSomeImage'));
echo $svg->asXML();

What version of the product are you using? On what operating system?
phpsvg 1.1 on Ubuntu 11.10

Thanks!

Original issue reported on code.google.com by rodrigos...@gmail.com on 23 May 2012 at 2:32

Attachments:

GoogleCodeExporter commented 9 years ago
Really, the PrettyXML is only used to make the XML outputs nice in texts 
editor, a option to to it or not is viable.

Original comment by trialfo...@gmail.com on 23 May 2012 at 4:22

GoogleCodeExporter commented 9 years ago
I will make the correction soon as possible.

Original comment by trialfo...@gmail.com on 23 May 2012 at 4:23

GoogleCodeExporter commented 9 years ago
Now the asXML has humanreadable paramater. Wait for publication to text it 
again.

Original comment by trialfo...@gmail.com on 12 Sep 2013 at 2:52

GoogleCodeExporter commented 9 years ago

Original comment by trialfo...@gmail.com on 12 Sep 2013 at 2:52