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

PHP Benchmarks

Performance comparison of PHP code alternatives.

Test: pack() v. sprintf()

The documentation describes sprintf() using %c as similar to chr(). It's an arguably cleaner syntax (if only using chars) than pack() uses - is it faster?

Run Again Test Menu


Unfortunately, no history for this test is available.


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

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

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

$GLOBALS['dummy'] = sprintf('%c%c%c%c', 65, 65, 65, 65);

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