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 "strtr()" was the faster by 0.0295 seconds, (5.008% faster)

strtr() 100%
str_replace() 94.992%

The strtr() test took 0.559 seconds.
The str_replace() test took 0.5885 seconds.


Each test case ran 20 random code order iterations consisting of 147,466 loops for a total of 2,949,320 runs.

  • Line execution difference (0.000010) milliseconds.
  • Avg difference (1.474) milliseconds per 147,466 loops.
  • Total difference 29.47 milliseconds for 2,949,320 loops

The iteration variablity for Code 1 was (2.1986) milliseconds and Code 2 was (2.9700) 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 (