PHP 5.2 benchmarks

Test procedures

edit

Circa r19192, things running on a MacBook w/ 2 GHz Core 2 Duo.

PHP 5.1.6 and 5.2.1RC2, both with APC 3.0.12p2 installed; when used via web server they're both connected via FastCGI to lighttpd accessed from the local machine.

Parser-cache hit

edit

Web hits with 'ab' to a short article copied from Wikipedia, 500 hits over 4 concurrent threads (2 threads per CPU core).

data="title=Religion_in_Brazil"

echo "Testing PHP 5.2..."
ab -n10 "http://katitzi.local/trunk/index.php?$data" 2>&1 > /dev/null
ab -n500 -c4 -v1 "http://katitzi.local/trunk/index.php?$data"

echo "Testing PHP 5.1..."
ab -n10 "http://katitzi.local/trunk/index.php51?$data" 2>&1 > /dev/null
ab -n500 -c4 -v1 "http://katitzi.local/trunk/index.php51?$data"


5.1:

Requests per second:    23.62 [#/sec] (mean)
Time per request:       169.32 [ms] (mean)
Time per request:       42.33 [ms] (mean, across all concurrent requests)
Transfer rate:          544.41 [Kbytes/sec] received

5.2:

Requests per second:    25.72 [#/sec] (mean)
Time per request:       155.54 [ms] (mean)
Time per request:       38.88 [ms] (mean, across all concurrent requests)
Transfer rate:          592.74 [Kbytes/sec] received

Parser-cache miss

edit

Same page, with ?action=purge (set $wgGroupPermissions['*']['purge'] = true to bypass the POST check)

5.1:

Requests per second:    21.13 [#/sec] (mean)
Time per request:       189.26 [ms] (mean)
Time per request:       47.32 [ms] (mean, across all concurrent requests)
Transfer rate:          488.38 [Kbytes/sec] received

5.2:

Requests per second:    21.80 [#/sec] (mean)
Time per request:       183.50 [ms] (mean)
Time per request:       45.87 [ms] (mean, across all concurrent requests)
Transfer rate:          502.79 [Kbytes/sec] received

Unicode normalization benchmark

edit

These should be more or less CPU-bound; the faster items use C-based string functions to try to do as much initial checking as possible, while the slower functions work more inefficiently, character by character in PHP.

5.2 seems to be going slower on the slow funcs, but faster on the fast ones.

Best out of a couple runs:

$ PATH=/opt/php51/bin:$PATH make bench
                                [ PHP 5.1.6 ]         [PHP 5.2.1RC1]
Testing testdata/washington.txt (English text)...
              cleanUp    4.8ms    6,606,526 bytes/s    9,436,211 bytes/s
                toNFC    2.7ms   11,816,767 bytes/s   16,887,564 bytes/s
                  NFC   87.8ms      359,233 bytes/s      364,635 bytes/s
        fastDecompose   25.1ms    1,256,362 bytes/s    1,270,449 bytes/s
    fastCombiningSort   26.0ms    1,212,871 bytes/s    1,253,920 bytes/s
          fastCompose   38.1ms      828,018 bytes/s      932,146 bytes/s
Testing testdata/berlin.txt (German text)...                            
              cleanUp    6.8ms    5,357,757 bytes/s    6,986,018 bytes/s
                toNFC   23.7ms    1,531,195 bytes/s    1,416,641 bytes/s
                  NFC  103.6ms      350,423 bytes/s      339,935 bytes/s
        fastDecompose   28.8ms    1,259,234 bytes/s    1,097,015 bytes/s
    fastCombiningSort   31.9ms    1,147,580 bytes/s      997,465 bytes/s
          fastCompose   45.1ms      811,947 bytes/s      811,479 bytes/s
Testing testdata/bulgakov.txt (Russian text)...                         
              cleanUp   43.2ms      853,876 bytes/s      932,362 bytes/s
                toNFC   27.4ms    1,345,930 bytes/s    1,195,614 bytes/s
                  NFC  123.5ms      298,314 bytes/s      290,939 bytes/s
        fastDecompose   38.0ms      970,401 bytes/s      869,243 bytes/s
    fastCombiningSort   33.8ms    1,104,975 bytes/s      965,824 bytes/s
          fastCompose   51.3ms      728,758 bytes/s      690,361 bytes/s
Testing testdata/tokyo.txt (Japanese text)...                           
              cleanUp   37.2ms      974,801 bytes/s    1,098,073 bytes/s
                toNFC   20.0ms    1,813,736 bytes/s    1,665,315 bytes/s
                  NFC   88.9ms      407,574 bytes/s      370,475 bytes/s
        fastDecompose   26.9ms    1,347,752 bytes/s    1,138,739 bytes/s
    fastCombiningSort   25.7ms    1,447,031 bytes/s    1,220,883 bytes/s
          fastCompose   38.0ms      977,961 bytes/s      902,098 bytes/s
Testing testdata/young.txt (Korean text)...                             
              cleanUp   42.7ms      859,242 bytes/s      952,375 bytes/s
                toNFC   19.5ms    1,880,293 bytes/s    1,702,271 bytes/s
                  NFC  297.9ms      123,161 bytes/s      120,552 bytes/s
        fastDecompose   85.2ms      430,533 bytes/s      395,409 bytes/s
    fastCombiningSort   45.0ms    1,769,757 bytes/s    1,532,289 bytes/s
          fastCompose  169.2ms      471,051 bytes/s      477,139 bytes/s

Parser tests

edit

The parser test suite does a lot of setup/teardown and isn't too efficient.

Best out of three runs:

$ time /opt/php52/bin/php maintenance/parserTests.php --quick --quiet
$ time /opt/php51/bin/php maintenance/parserTests.php --quick --quiet
5.1.6 5.2.1RC2 % faster
real 0m7.857s real 0m7.088s 10.8%
user 0m5.103s user 0m4.626s 10.3%
sys 0m1.624s sys 0m1.502s 8.1%