PHP Benchmarks

Performance comparison of PHP code alternatives.

Benchmarks by their nature are artificial:

We all know that so there is no need to prattle on about it. The results of these tests indeed need to be taken with a grain or salt, or a shot of Bourbon. The point is however, that some things are simply better practices and knowing those is a way forward and not an excuse to look back and change existing code. Performance follows the classic 80/20 Rule, if test a vs test b does not have > 20% difference, you are very likely optimized.

How it works:

The total number of test loops is set to try run the longest test for ~1 second. This total is then sub divided in to 20 test runs to get an average and margin of error. The test order is random in each group to attempt to minimize any preference or impact of server load on one test group vs another. Completed tests that have a low margin of error are recorded in to the historical statistical record.

Benchmark Group: addslashes

Benchmark Group: array

Benchmark Group: array_map

Benchmark Group: array_merge

Benchmark Group: cast

Benchmark Group: chr

Benchmark Group: classes

Benchmark Group: constants

Benchmark Group: create_function

Benchmark Group: date

Benchmark Group: dir

Benchmark Group: echo

Benchmark Group: equal

Benchmark Group: errors

Benchmark Group: exec

Benchmark Group: file

Benchmark Group: foreach

Benchmark Group: func

Benchmark Group: global

Benchmark Group: hash

Benchmark Group: if

Benchmark Group: ifor

Benchmark Group: include

Benchmark Group: index

Benchmark Group: is

Benchmark Group: keycreation

Benchmark Group: last

Benchmark Group: math

Benchmark Group: ob_start

Benchmark Group: preg

Benchmark Group: rand

Benchmark Group: recurse

Benchmark Group: socket

Benchmark Group: strpios

Benchmark Group: strpos

Benchmark Group: strtr

Benchmark Group: substr

Benchmark Group: urlencode


Running: Linux (x86_64:1 GB) PHP (7.2.19-1+ubuntu16.04.1+deb.sury.org+1)