Warning: Division by zero in /var/customers/webs/stc/benchmark/index.php on line 256 Test: create_function vs. closure inside loop

PHP Benchmarks

Performance comparison of PHP code alternatives.

Test: create_function() vs. closure inside loop

Using create_function vs anonymous lambda function in a loop

Run Again Test Menu


Unfortunately, no history for this test is available.


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

$a = $GLOBALS['a'];
for($i = 0; $i < 100; ++$i) {
	$callback = create_function('$n', 'return $n;');
	array_map($callback, $a);

The second test, "lambda", was:

$a = $GLOBALS['a'];
for($i = 0; $i < 100; ++$i) {
	$callback2 = function($n) { return $n; };
	array_map($callback2, $a);

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