Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Evert Pot's Blog:
iconv_substr vs mbstring_substr
Sep 30, 2011 @ 16:03:20

Evert Pot came across an interesting performance issue as he was working through an application that needed to do some string substitutions - the difference between iconv_substr, mb_substr and substr.

While working on an application I ran across a huge bottleneck which I isolated down all the way to the use of the iconv_substr function. If you ever wonder which is better to use, [the benchmark code in the post[ should help your decision.

His results changed quite a bit from machine to machine (and OS/platform to OS/platform) but one statistic stood out on them all - the iconv_substr was slower than mb_substr method....by a lot in one case (about 2100000% slower).

tagged: benchmark iconvsubstr mbstringsubstr substr substring

Link:

Christian Stocker's Blog:
Calling PHP function from XSLT vs. native XSLT functions benchmark
Mar 27, 2006 @ 12: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.

tagged: XSLT native functions user-defined substring substr XSLT native functions user-defined substring substr

Link:

Christian Stocker's Blog:
Calling PHP function from XSLT vs. native XSLT functions benchmark
Mar 27, 2006 @ 12: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.

tagged: XSLT native functions user-defined substring substr XSLT native functions user-defined substring substr

Link:


Trending Topics: