News Feed
Jobs Feed
Sections




News Archive
Christian Stocker's Blog:
Calling PHP function from XSLT vs. native XSLT functions benchmark
March 27, 2006 @ 06:55:47

One of the more underused thechnologies to come along these days is XSLT - that powerful langauge to style XML documents in a simple, "more correct" kind of way (seperation of data and layout). Most languages have support for this combination, including PHP - but what's the best way to combine PHP and XSLT? Christian Stocker took a look in this new post on the Bitflux blog.

After Rob's idea from yesterday about using XMLReader within XSLT I was wondering, how much of a slowdown calling PHP functions from XSLT is.

I wrote 4 different XSLT templates, which do a simple substring. One with the xslt function "substring", one with just calling the native PHP function "substr" and one with calling a user-defined function (which is also just calling "substr"). I called this 100 times (with one of those great recursive self-calling xslt-templates) and did call the "transformToXML" function a 100 times for each stylesheet. This means, we called the function 10'000 times for each benchmark run.

His bases the results off of a sample with no function call at all and, but running it through 100 times, came up with results that weren't all that surprising. In order of speed, the ranking (shortest time first) was: no call, xslt only, php native, and php userland. Using the PHP functions from inside of XSLT made the test quite a bit slower, but, as he notes, most users won't be running recursions of 100 each time they run a script.

1 comment voice your opinion now!
XSLT native functions user-defined substring substr XSLT native functions user-defined substring substr


blog comments powered by Disqus

Similar Posts

Internet Super Hero Blog: MySQL native driver for PHP: mysqlnd-5.0.1-beta available

IBM developerWorks: Use DB2 native XML with PHP

SitePoint PHP Blog: Living Dangerously with PHP and UTF-8

PHPro.org: Application Configuration

Hasin Hayder's Blog: Web scrapping in a smart way, making a "Today in History" object in PHP


Community Events











Don't see your event here?
Let us know!


language functional code conference release tool introduction community opinion object composer testing interview framework podcast example development series zendframework2 database

All content copyright, 2013 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework