PHP Benchmarks

Performance comparison of PHP code alternatives.

Test: exec vs. shell_exec

No Description

Run this test again Return to test menu

Result: Discarded

The test labeled "shell_exec()" was the faster by 0.0455 seconds, (5.137% faster)

shell_exec() 100%
exec() 94.863%

The shell_exec() test took 0.8399 seconds.
The exec() test took 0.8854 seconds.

Nitty-Gritty

Each test case ran 20 random code order iterations consisting of 212,773 loops for a total of 4,255,460 runs.

  • Line execution difference (0.000011) milliseconds.
  • Avg difference (2.274) milliseconds per 212,773 loops.
  • Total difference 45.48 milliseconds for 4,255,460 loops

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