PHP Benchmarks

Performance comparison of PHP code alternatives.

Test: exec vs. shell_exec

No Description

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

Result: Discarded

The test labeled "shell_exec()" was the faster by 0.1226 seconds, (8.977% faster)

shell_exec() 100%
exec() 91.023%

The shell_exec() test took 1.243 seconds.
The exec() test took 1.3656 seconds.

Nitty-Gritty

Each test case ran 20 random code order iterations consisting of 281,166 loops for a total of 5,623,320 runs.

  • Line execution difference (0.000022) milliseconds.
  • Avg difference (6.130) milliseconds per 281,166 loops.
  • Total difference 122.59 milliseconds for 5,623,320 loops

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