Il 20 giugno hanno rilasciato PHP 5.5.0. Oltre ad interessanti novità come i generators, il finally (finalmente :), l'inclusione di Zend OPcache nel core, si vocifera che sia la versione di PHP più veloce mai rilasciata. Ho deciso di testarla con il mio CMS preferito: SilverStripe. Il test è stato fatto su di una installazione di default di SilverStripe, versione 3.1.0-rc1 (in realtà pre-rc1, presa da github), fatta girare sul mio laptop di sviluppo, un quad-core I5 2.50GHz con 6Gb di ram e disco da 5200RPM, debian testing (jessie) con apache 2.2.22 e php-fpm.
I risultati sono sorprendenti: con php 5.5.0 ho un incremento delle performance pari a circa il 25%! Ecco i risultati del test:
####################################
## PHP 5.4.4-15.1 (debian jessie) ##
####################################
# ab -n 100 -c 10 http://ssdev-master.zk/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking ssdev-master.zk (be patient).....done
Server Software: Apache/2.2.22
Server Hostname: ssdev-master.zk
Server Port: 80
Document Path: /
Document Length: 4940 bytes
Concurrency Level: 10
Time taken for tests: 8.069 seconds
Complete requests: 100
Failed requests: 0
Write errors: 0
Total transferred: 534500 bytes
HTML transferred: 494000 bytes
Requests per second: 12.39 [#/sec] (mean)
Time per request: 806.872 [ms] (mean)
Time per request: 80.687 [ms] (mean, across all concurrent requests)
Transfer rate: 64.69 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.2 0 1
Processing: 269 778 133.8 800 1066
Waiting: 269 777 133.8 800 1066
Total: 269 778 133.7 800 1066
Percentage of the requests served within a certain time (ms)
50% 800
66% 846
75% 861
80% 874
90% 900
95% 952
98% 981
99% 1066
100% 1066 (longest request)
####################################
###### PHP 5.5.0 (compilato) ######
####################################
# ab -n 100 -c 10 http://ssdev-master.zk/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking ssdev-master.zk (be patient).....done
Server Software: Apache/2.2.22
Server Hostname: ssdev-master.zk
Server Port: 80
Document Path: /
Document Length: 4940 bytes
Concurrency Level: 10
Time taken for tests: 6.183 seconds
Complete requests: 100
Failed requests: 0
Write errors: 0
Total transferred: 534000 bytes
HTML transferred: 494000 bytes
Requests per second: 16.17 [#/sec] (mean)
Time per request: 618.251 [ms] (mean)
Time per request: 61.825 [ms] (mean, across all concurrent requests)
Transfer rate: 84.35 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.2 0 1
Processing: 191 597 112.2 615 790
Waiting: 191 597 112.2 615 790
Total: 191 598 112.2 615 790
Percentage of the requests served within a certain time (ms)
50% 615
66% 656
75% 670
80% 689
90% 716
95% 750
98% 781
99% 790
100% 790 (longest request)
####################################
## ############################## ##
####################################
Colto da entusiasmo ho deciso di provare qualche script di benchmark, giusto per vedere le differenze, e qui è arrivata la stranezza! Ho scaricato un paio di script di benchmarking php, li ho adattati per essere eseguiti da shell ed ho lanciato il benchmarking:
#################################### ## PHP 5.4.4-15.1 (debian jessie) ## #################################### Start : 06/24/2013 11:34:44 am Running from command line PHP version : 5.4.4-15.1 Platform : Linux ######################################## Math : 2.881 sec. String Manipulation : 3.280 sec. Loops : 2.174 sec. If/Else : 3.270 sec. ######################################## Total: : 11.604 sec. #################################### ###### PHP 5.5.0 (compilato) ###### #################################### Start : 06/24/2013 11:35:33 am Running from command line PHP version : 5.5.0 Platform : Linux ######################################## Math : 1.158 sec. String Manipulation : 1.536 sec. Loops : 0.450 sec. If/Else : 0.782 sec. ######################################## Total: : 3.927 sec.
Incredibile, il PHP 5.4 è quattro volte più lento in questo benchmark! Comincia però a venirmi il sospetto che ci sia qualcosa nella pacchettizzazione Debian che influisca sulle performance. La prova del nove la posso avere compilandomi un PHP 5.4 con le stesse opzioni di configure del php 5.5.0 ed eseguire nuovamente il test. Detto fatto:
#################################### ###### PHP 5.4.16 (compilato) ###### #################################### Start : 06/24/2013 11:38:27 am Running from command line PHP version : 5.4.16 Platform : Linux ######################################## Math : 1.277 sec. String Manipulation : 1.614 sec. Loops : 0.437 sec. If/Else : 0.752 sec. ######################################## Total: : 4.080 sec.
Ok, il risultato è più accettabile. Mi resta però il dubbio: perchè il PHP pacchettizzato da Debian è così lento? Saranno le estensioni caricate? Possibile però che influiscano così tanto?
© Copyleft 2025 g4b0 (Gabriele Brosulo). All rights reserved
Mappa del sito
Privacy Policy