Warning: Division by zero in /var/customers/webs/stc/benchmark/index.php on line 256 Test: chr v. pack

PHP Benchmarks

Performance comparison of PHP code alternatives.

Test: chr() v. pack()

Note that this test uses concatenation for many chr()'s vs. one pack(). In a case with many calls to pack(), the result might be different (but this is a less common use.)

Run Again Test Menu

Result

Unfortunately, no history for this test is available.

Code

The first test, "chr()", was:

$GLOBALS['dummy'] = chr(65) . chr(65) . chr(65) . chr(65);

The second test, "pack()", was:

$GLOBALS['dummy'] = pack('C4', 65, 65, 65, 65);

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