Archive for the ‘PHP’ Category

PHP 5.4 Brings Performance Improvements

A line in the current release notes for the PHP 5.4 beta states:

Improved: Improved Zend Engine memory usage and performance

Sounds good to me, and after my previous post on references I thought I’d run the same test with this new build (all times are in seconds):

I’d say that’s a decent improvement, though one that follows the same trend from the first post of using references with objects is slower than not using them.

As one final test, here’s the result of loading the FormBoss.net homepage several times in succession:

So about the same when performing standard page interpreting, if not a touch slower.

Links

http://qa.php.net/

Understanding and Using References In PHP

References are a feature of the C family of languages, and while not all that common in PHP, can be used and are quite handy in some situations. In this post I want to cover what references are and how we can (and may not want to) use them in our PHP code.

Read More

Creating A PHP Extension

“Stock” PHP has a large number of extensions that cover just about every web-development task you can imagine. From file and FTP operations to database communication, chances are PHP already has you covered.

Their is one area where PHP falls flat however, and that’s intensive data processing. As PHP internally stores all user-space variables in a hash-table, algorithms that require heavy manipulation and lookups of these items will always be slow.

Of course PHP will also fall flat for us if we need some capabilities that no extension provides.

In this post we’ll learn about the solution to both of these issues: building custom PHP extensions. The reason why this post even exists is because of an excellent PHP tool called: ext_skel, as with it we can quickly create our own PHP extensions that would otherwise take many laborious hours of trial and error.

Read More

Benchmarks: JavaScript vs. PHP vs. HPHP vs C++

Just a quick spattering of some benchmarks I ran while testing a program I’m developing internally.

The first three are of the fannkuch benchmark found on the sunspider test site, only ported over to C++ and PHP in addition to the JS version. The browser used for all tests was Firefox 5.

The HPHP listing is a compiled Hip Hop PHP version, which is interesting as it shows the relative difference between it and vanilla PHP.

The last item, Benchmark.php, is the same benchmark file you’ll find in a PHP source download.

See the full benchmarks after the jump!

Read More

XML Namespaces And XPath

In this post we’ll cover a topic you’ll no doubt run into when dealing with SOAP web services: parsing XML data that uses namespaces via XPath.

As I’m a PHP guy this will be PHP centric in that we’ll use SimpleXML for our parsing needs. The techniques and general ideas presented herein however, are applicable to almost all XML/XPath processing languages.

Read More

Aesop – A Hip Hop PHP UI

Download the Complete (and free, as in open source free) Aesop + HPHP files from right here.

PHP is my favorite language, bare none. It’s simple, elegant, and fun to use. Problem is, for highly trafficked sites it’s a touch slow and can be quite memory hungry. If you’re Facebook this can lead to problems, which is why they invented Hip Hop PHP (HPHP), a collection of tools and technology that turns our slow and hungry PHP code into lean and mean C++.

Ok, So Just How Fast Is It?

As a quick comparison I created a simple FormBoss form and ran Apache Bench (ab from the command line), to get a sense of the speed difference between Apache 2.2 and HPHP.

The top two tests are when running our simple .php files, the bottom test is when serving a simple 62 byte .xml file with 100 concurrent users:

**It’s important to note these numbers will be lower when running though a network and calling a database. Also, while other servers like Cherokee can be twice as fast as Apache, HPHP is still nearly twice as fast again.

So yes, qualifications aside, HPHP is very fast indeed.

Sure these numbers are fantastic, but using HPHP means compiling the source from scratch and then using a series of command-line switches to run and manage the compiled PHP code.

No longer–In my spare time I’ve created and now released an open-source front-end UI to HPHP.

Read on to learn more, or just download the files!

Read More

A New Way To Think About The MVC Design Pattern

One of the gripes I have with implementing an MVC design pattern in PHP development is lack of tools to efficiently work on the model, view, and controller at the same time. Taking the MVC path means, like it or not, traversing three times as many windows and editors. It’s just not efficient for the way I want to work. And so, I’ve got an idea…

Read More

HipHop PHP Benchmark

Update: Looking to try HPHP? Take a peek at my open-source HPHP UI.

hip-hop

What are we looking at?

The chart above shows Ubuntu in a 2 and 8 core configuration (the x2 and x8), along with a Server 2008 instance running a benchmark program to stress a PHP based webserver.

What does it mean? The good folks over at FaceBook recently released a custom tool called HopHop that rewrites PHP into native C++ code. The upshot to this, as you can see, is bare-bones PHP code, that is, code which relies on math and loops and such, is much, much faster. Of course other code should be faster as well, though I have yet to benchmark more complex scripts.

Read More

JW Player Playlist Editor GUI

Here’s a simple script for managing/editing playlists in the popular JW Player.

It’s called [ Media Manager For JW Player ], and is GNU General Public License software which means it’s free and anyone can edit it.

That means I hope that this little manager will be of use to someone, but more importantly, may grow into something larger if others want it pick it up and run with it.

The Media Manager For JW Player Interface

The Media Manager For JW Player Interface

Read More

b2Evo to WordPress Export Script

We recentlly had to convert a few b2Evolution blogs to WordPress 2.8, something that is apparentlly common but not very standardized. Thus, after some digging I found a script, but it did not work with the newest versions of each component.

After a few tweaks I was able to get it working again, and now I would like to share the result with this slightly modified b2Evo to WordPress Import Script:

import-b2evolution-wp2

If you are trying to import from another system, this codex link may be of use.