Aug 14

Blitz for PHP

l love Smarty, the PHP templating engine. It makes presentation development a lot simpler and more pleasant.

However, there’s always a guilt factor involved, because whenever you introduce an abstraction, you introduce processing overhead. Smarty is written in pure PHP, so there’s extra processing post-parse, which will always slow things down.

Enter Blitz. It’s a PHP templating library written in C and distributed as a compiled PHP extension. As such, it’s awfully fast. The official page has a bunch of benchmarks, but this article subjects Blitz to some real-world tests and compares it to Smarty and native PHP file includes. The results:

Blitz won two of the three tests and came in a close second in the last [to native PHP]. Of course, one could argue that PHP “won” the first test since there was no need to be tested on instantiation.

Considering the short amount of time Blitz has been under active development, its sheer speed is rather amazing.

I’ll admit that it’s impressive. A complex template requiring 10,000 iterations of something was generated by Blitz in .07 seconds. In all the tests, Smarty came in between 30% and 50% slower than Blitz. In fact, Blitz was awfully close to native PHP in most cases.

Now, to be fair, let’s note a couple things:

  1. Smarty is much more mature. There’s a stronger feature set and a lot more support available.

  2. For most applications, we’re splitting hairs. I know I said “30% and 50% slower,” but in reality, this is the different between .0001 seconds and .006 seconds for a simple template. Let’s be honest: I don’t think I’ve written an app where 59 ten-thousands of a second was going to change much. However, I know these apps exist, so there’s certainly a place for this.

Of course, the “extra processing” argument against Smarty has been raised before. Savant is a PHP templating engine that uses PHP as its actual language. Gosh, how quaint.


Comments

by Owen,   June 12, 2008 9:58 AM  

Well speaking as a developer of the PHPulse framework, the world's fastest (yes, no one has beaten our benchmarks yet), we try to look at every tiny aspect to squeeze every split second we can. The more of those split seconds you can squeeze, they all add up to seconds. In a benchmark of 'ab -n10000 -c1000' on a 1.4ghz machine, PHPulse can do 471 requests per seconds... on average.

I'm strongly considering moving to Blitz so I can start getting this over 600 requests per second.


by Deane,   June 12, 2008 12:19 PM  

I’m strongly considering moving to Blitz so I can start getting this over 600 requests per second.

Make it optional. Blitz involves installing a compiled extension to your PHP install, which out of reach for most people on hosted accounts.

You seem obsessed with your RPS number. Putting your framework out of reach for most people just to bump that number higher will do more harm than good.


by Eberhard,   June 25, 2008 5:22 PM  

Not everyone should be striving for speed - but someone should, be it just to set the frame and demonstrate the consequences. So please, Owen and phpulse workers, continue the good work!



Add Comment


Want to advertise on this site? Contact FM.
Web Hosting Web hosting, dedicated servers and Web design services
Laser Toner Cartridges UK laser toner, toner cartridges, hp toner, lexmark toner, samsung toner, canon, toner, epson toner, oki toner, kyocera toner, xerox toner, remanufactured toner, compatible toner
Direct TV Deals Free 4 room direct tv deals. no equipment to buy. free fast professional direct tv installation. this is the best direct tv deal available anywhere.
SEO Article Learn from the experts with our SEO article.
rope light Shopping with birddog distributing, inc., gives you access to the lowest prices, the best customer service and the quickest delivery times possible.
Laptop AC Adapter We offer genuine factory direct replacement AC adapters.
Direct TV Best satellite TV deals.
Direct TV Deals Direct TV programming deals are varied and include packages containing from 50 channels up to over 250 channels.
8mm film to DVD Retain family memories with the only frame by frame digital restoration service in the United States for your 8mm film to DVD today
Rubber Stamp Shop for custom self-inking stamps, hand stamps, address stamps, label stamps, check endorsement stamps, check deposit stamps, date stamps, pre inks, pocket stamps, ink and much more!