Warning: Division by zero in /var/customers/webs/stc/benchmark/index.php on line 256 Test: file vs. fgets (array)

PHP Benchmarks

Performance comparison of PHP code alternatives.

Test: file() vs. fgets() (array)

Run Again Test Menu

Result

Unfortunately, no history for this test is available.

Code

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

$lines = file('supplement/dummy.inc');
foreach ($lines as $line)
	$GLOBALS['dummy2'] = rtrim($line);

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

$fp = fopen('supplement/dummy.inc', 'rt');
while (!feof($fp))
	$GLOBALS['dummy2'] = rtrim(fgets($fp));
fclose($fp);

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