Every so often I write a script to measure how long various common things in my current scripting language take. The difference between the versions is quite large. The last php-benchmark is available, but is 2014 version of PHP.

Third party benchmarks

I haven't checked that the site testers download all the resources, i.e. pull a page, then download all the attached JS and CSS. This pipelining is a useful feature of HTTP1.1.

  1. http://www.phpbench.com/
  2. http://www.php-benchmark-script.com/
  3. https://github.com/fotuzlab/appgati
  4. http://www.metamorphosite.com/php-benchmarks-loops-arrays
  5. http://jmeter.apache.org/
    1. this is a good reputation, but its for Java
  6. http://www.cyberciti.biz/tips/howto-performance-benchmarks-a-web-server.html
    1. this is for Apache not php, but is useful as a structure
  7. http://acme.com/software/http_load/
    1. again a site tester
  8. http://juditacs.github.io/2016/03/19/wordcount2.html
    1. my random reading found this. This is a simple IO based problem, solved in many languages, and the results tabulated. I am not saying that this is the best code in each language, and certainly I could shave something like 15% of execution time off the PHP script; however this compares PHP to other languages. Its funny that Node drops down the scores, as soon as people start quoting numbers.

My 2017 performance benchmark

This results are for PHP 7.1.3-3 (cli) (built: Jun 22 2013 06:27:20) running on Linux 4.4.0-36-generic.

Test of:Duration (n=100000)deltaRAM
PHP version:7.1.3-3+deb.sury.org~xenial+1 3.1.0Linux meow 4.4.0-36-generic
When/ where:2017-04-23meow
Stats for creating LD1 0.0008s0 MB
Stats for creating LD2 0.1014s0 MB
Stats for creating LD3 0.0022s0 MB
Stats for creating LD4 0.0020s0 B
[0] linear increment (1php byte code)0.0022s0 B
[1] linear increment (1php byte code)0.0017s0 B
[2] linear float addition0.0025s0 B
[3] linear float increment0.0027s0 B
[4] linear float increment (+1)0.0027s0 B
[5] float increment (cast alot)0.0032s0 B
[6] linear float increment(cast)0.0028s0 B
[7] string creation0.0020s0 B
[8] string concat (inc RAM)0.0038s0 B
[9] html entities ~ plain0.0157s0 B
[10] html entities ~ entities0.0212s0 B
[11] func int addition0.0043s0 B
[12] func float addition0.0047s0 B
[13] func string creation0.0036s0 B
[14] func string cat0.5939s0 B
[15] reference string cat0.0075s0 B
[16] reference int increment0.0050s0 B
[17] EVAL linear float increment0.1447s0 B
[18] EVAL linear int increment 0.1450s0 B
[19] EVAL linear float addition0.1552s0 B
[20] EVAL string creation0.1578s0 B
[21] EVAL string concat0.1587s0 B
[22] for loop1.2510s0 B
[23] foreach ($v only) loop0.9106s0 B
[24] while list0.0088s0 B
[25] foreach ($k=>$v) loop1.4072s0 B
[26] simple array_key_exists0.0041s0 B
[27] isset0.0038s0 B
[28] in_array0.0041s0 B
[29] empty0.0027s0 B
[30] simple array_key_exists largeData0.0041s0 B
[31] isset largeData0.0027s0 B
[32] in_array largeData1.3168s0 B
[33] empty largeData0.0028s0 B
[34] largerData2 array_key_exists0.0042s0 B
[35] isset largeData20.0027s0 B
[36] largerData2 in_array30.8244s0 B
[37] empty largeData20.0029s0 B
[38] largerData3 array_key_exists0.0054s0 B
[39] empty largeData30.0036s0 B
[40] largerData3 isset0.0036s0 B
[41] largerData3 in_array1.0048s0 B
[42] largerData4 array_key_exists0.0050s0 B
[43] isset largeData40.0035s0 B
[44] largerData4 empty0.0036s0 B
[45] largerData4 in_array0.6312s0 B
[46] uniqid5.5032s0 B
[47] md50.0358s0 B
[48] sha10.0448s0 B
[49] sha2560.0790s0 B
[50] sha5120.1939s0 B
[51] tiger128,30.0572s0 B
[52] adler320.0201s0 B
[53] crc32b0.0222s0 B
[54] whirlpool0.1592s0 B
[55] haval224,30.1048s0 B
[56] strcmp by == match0.0031s0 B
[57] strcmp by == match 2vars0.0030s0 B
[58] strcmp by == nomatch0.0032s0 B
[59] strcmp by strcmp0.0080s0 B
[60] strcmp by !strcmp0.0081s0 B
[61] strcmp by strcmp 2vars0.0081s0 B
[62] strcmp by strstr0.0111s0 B
[63] strcmp by preg_match 10.0135s0 B
[64] global obj method call0.0049s0 B
[65] local obj method call0.0048s0 B
[66] local obj method call0.0048s0 B
[67] via call_user_func_array0.0214s0 B
[68] if statement0.0018s0 B
[69] switch statement0.0040s0 B
[70] ternary statement0.0031s0 B