PHP Benchmarks

Performance comparison of PHP code alternatives.

Test: rand vs. mt_rand

No Description

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

Result: Saved

The test labeled "mt_rand()" was the faster by 0.0013 seconds, (0.257% faster)

mt_rand() 100%
rand() 99.743%

The mt_rand() test took 0.5146 seconds.
The rand() test took 0.5159 seconds.


Each test case ran 20 random code order iterations consisting of 131,534 loops for a total of 2,630,680 runs.

  • Line execution difference (0.000001) milliseconds.
  • Avg difference (0.066) milliseconds per 131,534 loops.
  • Total difference 1.32 milliseconds for 2,630,680 loops

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


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

$GLOBALS['dummy'] = rand(0, 1000);

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

$GLOBALS['dummy'] = mt_rand(0, 1000);

Running: Linux (x86_64:1 GB) PHP (