PHP Benchmarks

Performance comparison of PHP code alternatives.

Test: exec vs. shell_exec

No Description

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

Result: Discarded

The test labeled "exec()" was the faster by 0.0173 seconds, (2.732% faster)

exec() 100%
shell_exec() 97.268%

The exec() test took 0.6163 seconds.
The shell_exec() test took 0.6336 seconds.

Nitty-Gritty

Each test case ran 20 random code order iterations consisting of 143,431 loops for a total of 2,868,620 runs.

  • Line execution difference (0.000006) milliseconds.
  • Avg difference (0.865) milliseconds per 143,431 loops.
  • Total difference 17.31 milliseconds for 2,868,620 loops

The iteration variablity for Code 1 was (2.1823) milliseconds and Code 2 was (1.5860) 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.15-1+ubuntu16.04.1+deb.sury.org+1)