PHP Benchmarks

Performance comparison of PHP code alternatives.

Test: exec vs. shell_exec

No Description

View test history (7) Run this test again Return to test menu

Result: Discarded

The test labeled "exec()" was the faster by 0.0691 seconds, (5.939% faster)

exec() 100%
shell_exec() 94.061%

The exec() test took 1.0942 seconds.
The shell_exec() test took 1.1632 seconds.

Nitty-Gritty

Each test case ran 20 random code order iterations consisting of 273,333 loops for a total of 5,466,660 runs.

  • Line execution difference (0.000013) milliseconds.
  • Avg difference (3.454) milliseconds per 273,333 loops.
  • Total difference 69.08 milliseconds for 5,466,660 loops

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

Code

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

exec('ls');

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

shell_exec('ls');

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