PHP Benchmarks

Performance comparison of PHP code alternatives.

Test: system vs. shell_exec

No Description

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

Result: Saved

The test labeled "shell_exec()" was the faster by 0.0002 seconds, (0.014% faster)

shell_exec() 100%
system() 99.986%

The shell_exec() test took 1.0719 seconds.
The system() test took 1.072 seconds.

Nitty-Gritty

Each test case ran 20 random code order iterations consisting of 293,103 loops for a total of 5,862,060 runs.

  • Line execution difference (0.000000) milliseconds.
  • Avg difference (0.008) milliseconds per 293,103 loops.
  • Total difference 0.15 milliseconds for 5,862,060 loops

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

Code

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

system('ls');

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

echo shell_exec('ls');

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