Welcome!

PHP

This is a free, open source PHP benchmark script that can be run on any web server that has PHP 4.2.0 or later installed. The idea came to me when I was planning on building a web server for a small business that offered a web application built on PHP. I wanted to know how fast various hardware and software configurations performed, but I couldn’t find any easy, simple, free ways to know what kinds of hardware/software configurations run PHP the best.  So, I wrote one myself.  :)

I invite you to download and run the benchmark on your web server and upload your results. If you have feedback or ideas about how to improve the benchmark or website, contact me at nick@freephpbenchmark.com.  I’ve seen some interesting results from the more than 200+ uploaded results between the OS and versions of PHP.  Please help everyone learn and see how your PHP server config measures up.

Download

Requirements: PHP 4.2.0 or greater; for best detailed system spec detection use Windows or Linux. Note: If you submit your scores, but your hardware config wasn’t detected, email me with your details and I’ll add it. Also, CPUs with SpeedStep may not be accurate, since the CPU clock speed may change during the benchmark.

,

No Comments

Performance differences between equivalent PHP functions

As part of writing code, a developer always should try to optimize and make the code run as efficiently as possible.   While learning PHP, often you may see something as simple as looping through an array as something where it just works.   However, some certain ways of writing code may not use the language’s most efficient operations or built-in functions/methods.

For example, consider looping through an array.  It’s a given that the following examples will result in the same output:

$array= new Array(…);

for($i=0; $i < sizeOf($array); $i++) {

echo $array[$i];

}

is functionally the same as

$array= new Array(…);

$size = sizeOf($array);

for($i=0; $i < $size; $i++) {

echo $array[$i];

}

However, the performance of the calls are completely different. With an array with 1,000 keys the first one will take 891% longer than the equivalent code that pre-calculates the size of the aray.  Obviously, the sizeOf() function takes time and doing it over and over and over has a substantial and significant hit on your application’s performance.   So, just remember that profiling and benchmarking code can really make a difference.  Looping through your array on an old Pentium III server with optimized code may be as fast as unoptimized code on a quad-core Xeon.

Check out some great sites that help show a few of the ways that you can improve your PHP application’s performance by showing benchmarks between different ways to write code.

  1. The PHP Benchmark — good examples of the difference between functionally equivalent code.
  2. PHP Benchmark Tests — again, good examples with specific results between PHP functions.

No Comments

Learning PHP presentations

While in college, I was asked on a few occasions to give presentations to the university’s Association of Systems Management (ASM) club on what PHP is and how it works–kind of an introduction to let everyone know how great it is and how well it works. My first presentation was in 2005 and then I followed up with two more in 2006, during the last year of my graduate work. I’ve dug up the presentations and posted them online below for anyone to reference. I’ve included demo code with the 2006 presentations (includes demo of consuming web services, AJAX calls, etc.)

  • PHP Night - March 29, 2005 (presentation only)
    • Overview of PHP
    • Syntax, datatypes, control structures, structures, objects
    • Advantages/disadvantages
    • Examples
    • Additional resources
  • PHP Night #1 - Oct. 5, 2006 (presentation and sample code)
    • Why use PHP?
    • Advantages/disadvantages
    • Development tools
    • Installing PHP on Windows
    • Examples:
      • Hello world
      • Querying MySQL database
      • Creating a mashup with Google Maps web service API
      • Upload and process image files with PHP’s image library
  • PHP Night #2 - Oct. 26, 2006 (presentation and sample code)

Hopefully these will give some of you who are learning and getting into PHP a taste of how it works and of all the things that you can do with it!

,

No Comments