News Feed
Jobs Feed
Sections




News Archive
feed this:

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

Michael Dowling:
Favor Hash Lookups Over Array Searches
March 21, 2014 @ 10:47:34

Michael Dowling has a recent post to his site comparing the performance of hash lookups versus array searches.

A common programming requirement is to match a string against a set of known strings. For example, let's say you were iterating over the words in a forum post and testing to see if a word is in a list of prohibited words. A common approach to this problem is to create an array of the known prohibited words and then use PHP's in_array() function to test if the string is found in the list. However, there's a simple optimization you can make to significantly improve the performance of the algorithm.

He includes two pieces of sample code - one showing the searching of an array using in_array and the other running an isset to locate a key. He points out that the in_array method is quite a bit slower than the hash (key) lookup and includes a benchmark script to prove it.The results are pretty clear, with the hash lookup coming in about 480% faster than the in_array. He also points out that as the size of the strings you're comparing grows, the performance of in_array drops even more.

0 comments voice your opinion now!
hash lookup search array inarray benchmark

Link: http://mtdowling.com/blog/2014/03/17/hash-lookups-over-array-search/

Simon Holywell:
HHVM vs Zephir vs PHP The showdown
March 03, 2014 @ 12:38:14

Simon Holywell has posted what he calls a "showdown" between HHVM, Zephir and PHP comparing various benchmarks (based on a Mandelbrot Set fractal).

Since its inception the slow running speed of PHP has been widely publicised and over the years there have been a number of improvements. [...] It has become more interesting recently however with three projects looking for improvements in different ways. The core has adopted the Zend OPcache for future versions of PHP, Facebook has been working on a just in time compiler called HipHop VM and the team that brought us Phalcon framework have created Zephir.

All of these projects have chosen to tackle the issue of PHP's speed via different avenues. It has therefore left one simple question - who's making the biggest improvements? Who's the fastest?

He briefly introduces the "contenders" for those not familiar with them and gets right into the benchmarking process. He shares the link to the tests he used and a few notes about the HHVM setup that could account for lower numbers. He shares his results in a few graphs or you can grab the CSV data yourself and parse it. The entire setup is also over on GitHub if you'd like to just check that out.

0 comments voice your opinion now!
showdown benchmark performance hhvm zephir opcache

Link: http://simonholywell.com/post/2014/02/hhvm-vs-zephir-vs-php-the-showdown.html

HHVM Blog:
FasterCGI with HHVM
December 18, 2013 @ 09:19:35

On the HHVM blog today they've posted an announcement about a new feature of this already powerful environment to help broaden the user base - FastCGI support.

Today, we are happy to announce FastCGI support for HHVM. FastCGI is a popular protocol for communication between an application server (e.g. running your PHP code) and a webserver. With support for FastCGI, you will be able to run HHVM behind any popular web server (Apache, Nginx, Lighttpd, etc). The webserver is in charge of handling all the intricate details of the HTTP protocol. HHVM is in charge of what it does best, running PHP code blazingly fast.

The post goes on to talk about how it all works including how it enables an instance of HHVM to run between requests (and serving multiple requests in parallel). It uses asynchronous I/O and a separate set of worker threads to execute the code. The rest of the post shares the results of a few benchmarks and gives you a step-by-step guide to getting it up and running.

0 comments voice your opinion now!
hhvm fastercgi fastcgi install benchmark introduction hiphop

Link: http://www.hhvm.com/blog/1817/fastercgi-with-hhvm

Ulf Wendel:
PHP Memcache access to MySQL 5.7, faster? Redis?
December 13, 2013 @ 12:56:50

In a new post to his site Ulf Wendel shows an alternative use for the PHP Memcache functions - using them to query MySQL tables (InnoDB) in much the same way. He also tosses in Redis as another version to compare the performance against (for fetching key/value pairs).

PHP users can use two client protocols to query MySQL 5.6 and later. Not only standard SQL access but also faster key-value access to InnoDB tables is possible using the Memcache protocol. The MySQL benchmark team reports crazy figures. Of course, on hardware that makes the average PHP meetup visitor roll his eyes and say "yeah, Oracle, *yawn*". I've repeated my plain PHP benchmarks on an i3 desktop. And, I've added Redis to the game.

He goes through and compares a few different things with some simple benchmarks around operations per second:

  • MySQL 5.6 Memcache vs. MySQL 5.7 Memcache vs. Memcache vs. SQL
  • MySQL vs. Memcache vs. Redis

For each he's graphed out the results of the benchmarking with some surprising results for those that may thing MySQL isn't as suited as Redis for something like this.

0 comments voice your opinion now!
mysql redis innodb memcache benchmark key value

Link: http://blog.ulf-wendel.de/2013/using-phps-memcache-interface-to-query-mysql-5-7/

Phil Sturgeon:
Benchmarking Codswallop NodeJS v PHP
November 12, 2013 @ 09:21:29

Phil Sturgeonhas posted about some Node.js vs PHP benchmarks that someone linked him to concerning web scraping. The article suggests that Node.js "owns" PHP when it comes to this but, as Phil finds out, there's a bit more to the story than that.

Sometimes people link me to articles and ask for my opinions. This one was a real doozy. Oh goody, a framework versus language post. Let's try and chew through this probable linkbait [where] we're benchmarking NodeJS v PHP. Weird, but I'll go along with it. Well, now we're testing cheerio v PhpQuery which is a bit different, but fine, let's go along with it.

Through a little discovery, Phil noticed phpQuery using file_get_contents, a blocking method for fetching the remote pages to scrape. Node.js instead uses a non-blocking method, meaning multiple files can be fetched at the same time. In answer to this blocking vs non-blocking, he decided to run benchamrks against a few cases - Node.js/Cherrio, PHP/phpQuery and his own, more correct comparison to the Node option - PHP/ReactPHP/phpQuery. He's shared his results, showing a major difference between the straight phpQuery and the React-based version.

It seems likely to me that people just assume PHP can't do this stuff, because by default most people arse around PHP with things like MAMP, or on their shitty web-host where is is hard to install things and as such get used to writing PHP without utilizing many extensions. It is probably exactly this which makes people think PHP just can't do something, when it easily can.
0 comments voice your opinion now!
nodejs reactphp webpage scraping benchmark compare

Link: http://philsturgeon.co.uk/blog/2013/11/benchmarking-codswallop-nodejs-v-php

Liip Blog:
HHVM with Symfony 2 looks amazing
October 29, 2013 @ 10:13:47

On the Liip blog today Christian Stocker shares some of the interesting results he's found when working with Symfony2 on the HipHop VM (based on Facebook's work around the HipHop version of optimized PHP). The project recently announced better framework support, so Christian thought he'd give it a try.

We're currently building a Symfony2 based application, which has pretty high performance requirements (but we can mostly achieve them with varnish), so I went and did some performance tests on that real-life app. [...] In short, the numbers were amazing. I also compared PHP 5.3 with APC against 5.5 with opcache, that alone gave some pretty decent improvements.

He talks about the configuration (hardware and software) he used for the testing and the Apache Bench tool to make the requests. He includes a few tables of the request/response result times comparing the HHVM, PHP 5.3 and PHP 5.5 for:

  • Requests per second, small response
  • Requests per second, middle response
  • Requests per second, large response
  • Median response time in ms, short response
  • Median response time in ms, middle response
  • Median response time in ms, large response

Each also comes with an accompanying graph for those wanting a quick glance version of the results.

0 comments voice your opinion now!
hiphop virtualmachine vm hhvm symfony2 benchmark results

Link: http://blog.liip.ch/archive/2013/10/29/hhvm-and-symfony2.html

MySQL Performance Blog:
SSL Performance Overhead in MySQL
October 11, 2013 @ 11:30:28

On the MySQL Performance Blog there's a recent post looking at the impact of SSL in regards to the overall performance of your application. This is part one of a two part series and focuses largely on the results of two tests - one with connection pooling and the other to evaluate connection time.

Some of you may recall my security webinar from back in mid-August; one of the follow-up questions that I was asked was about the performance impact of enabling SSL connections. My answer was 25%, based on some 2011 data that I had seen over on yaSSL's website, but I included the caveat that it is workload-dependent, because the most expensive part of using SSL is establishing the connection. Not long thereafter, I received a request to conduct some more specific benchmarks surrounding SSL usage in MySQL, and today I'm going to show the results.

He details the environments used for testing including the hardware specs and the version of the software installed. The scripts (really just bash scripts that call sysbench) are included in the post and the results of the tests are both graphed out and dumped in tabular form. The results are pretty surprising, mostly having to do with just how much of an impact the SSL has on the the requests. He makes a few recommendations at the end of the post on how you can mitigate these problems though (hint: it's not about MySQL per se).

0 comments voice your opinion now!
performance overhead mysql ssl results benchmark sysbench

Link: http://www.mysqlperformanceblog.com/2013/10/10/mysql-ssl-performance-overhead/

PHPixie:
Benchmarking Autoloading vs Combining classes into a single file
October 10, 2013 @ 11:48:44

On the PHPixie site there's a new post comparing the overall performance of autoloading versus a single-file approach when it comes to getting the best for your application. They point to the Fat-free Framework as an example of the single file approach.

Thinking about ways of further improving PHPixie I started looking at other projects for inspiration. For example the Fat-Free framework boasts on being contained in a single file. This got me thinking about making a tool for merging all project classes together with vendor libraries into a single for performance boost. MAking such a tool is a fairly trivial task, but still I wanted to be sure it would actually be useful, so I decided to benchmark autoloading classes with composer vs combining them into a single file.

The test script for the benchmarking is included in the post as well as the results from their test runs. In some the XCache extension was used to cache the opcodes, showing a noticeable change from the single-file approach. There's also a measurement of an average framework (autoloaded) request versus the all-in-one method with slightly surprising results. The post also ends with a recommendation for the Composer users out there - using the optional flag to generate a classmap to (slightly) help with autoloading speed.

0 comments voice your opinion now!
benchmark autoload phpixie combined class performance

Link: http://phpixie.com/blog/benchmarking-autoloading-vs-combining-classes-into-a-single-file/

Kevin Schroeder:
More - The file system is slow
September 30, 2013 @ 10:44:29

As a follow-up to his previous article about the (minimal) overhead from logging, Kevin Schroeder has this new post focusing on the common belief that writing to the file system is the slowest method.

I had a conversation the other day by a person I respect (I respect any PHP developer who knows how to use strace) about the cost of file IO. My assertion has been, and has been for a long time, that file IO is not the boogeyman that it is claimed to be. So I decided to test a cross between those two posts.

His test was to write one million log records to two different sources - the normal physical file system, a RAM drive - one run with a file handle that's left open and the other with a new handle each time. He shows how he made the RAM drive and the PHP he used for the test (running in a VM). He graphs out the results with some interesting results...but you'll have to read the post for that.

0 comments voice your opinion now!
file system slow write log overhead benchmark ramdisk graph

Link: http://www.eschrade.com/page/more-on-the-file-system-is-slow/

Greg Freeman:
Your PHP Framework Choice doesn't Matter
August 22, 2013 @ 11:45:18

In this new post Greg Freeman suggests something contrary to what most PHP developers (and framework supporters) believe - your choice of PHP frameworks doesn't matter...if you're basing it on speed.

I'm talking about the speed of PHP and more specifically, evaluating frameworks and tools based on "speed". If you have been in the PHP developer community for more than a few months, you would have seen at least a few discussions about what the fastest PHP framework is, as if this were one of the first key metrics you should evaluate first when choosing a framework for your team. You may even be contemplating switching from your current framework because you heard of a new framework that is faster. In the rest of this article, I'm going to do my best to show you why this not the best line of thinking and provide alternate and in my opinion better metrics for evaluating tools.

He talks about "frontend" versus "backend" PHP developers and how most PHP devs fit into the first category, not knowing how their applications really execute on the backend. This includes a pretty high-level concept of "speed." For his examples, he sets up a WordPress instance and fills it with some dummy content. He illustrates how, with a bit of tweaking on the "backend" side of things (server, environment, etc) the performance of the application can be greatly varied. He includes the specs for the environment he ran the tests in, some of the things he changed and a summary of the results.

0 comments voice your opinion now!
framework choice speed benchmark frontend backend environment

Link: http://www.gregfreeman.org/2013/your-php-framework-choice-doesnt-matter


Community Events











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


facebook package security hack podcast composer code language symfony2 introduction unittest hhvm framework example overview install release component opinion application

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