PHP Benchmarks

Performance comparison of PHP code alternatives.

Test: strtr vs. str_replace on long strings

No Description

Run this test again Return to test menu

Result: Discarded

The test labeled "str_replace()" was the faster by 0.0473 seconds, (6.445% faster)

str_replace() 100%
strtr() 93.555%

The str_replace() test took 0.6861 seconds.
The strtr() test took 0.7333 seconds.


Each test case ran 20 random code order iterations consisting of 172,943 loops for a total of 3,458,860 runs.

  • Line execution difference (0.000014) milliseconds.
  • Avg difference (2.363) milliseconds per 172,943 loops.
  • Total difference 47.26 milliseconds for 3,458,860 loops

The iteration variablity for Code 1 was (7.8579) milliseconds and Code 2 was (4.4305) milliseconds. The lower and the closer together there values are the more accurate the results are.


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


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


Running: Linux (x86_64:1 GB) PHP (