AM
Size: a a a
AM
F
<?phpможет я что-то не так понял?
declare(strict_types=1);
class Test {
}
function countTests(Test &...$tests) {
return count($tests);
}
$tests = [];
for ($i = 0; $i < 100; $i++) {
$tests[] = new Test();
}
$begin = microtime(true);
for ($i = 0; $i < 100000; $i++) {
countTests(...$tests);
}
echo 'Time: ' . round(microtime(true) - $begin, 3) . "\n";
VS
<?phpможет я что-то не так понял?
declare(strict_types=1);
class Test {
}
function countTests(Test &...$tests) {
return count($tests);
}
$tests = [];
for ($i = 0; $i < 100; $i++) {
$tests[] = new Test();
}
$begin = microtime(true);
for ($i = 0; $i < 100000; $i++) {
countTests(...$tests);
}
echo 'Time: ' . round(microtime(true) - $begin, 3) . "\n";
VS
KN
<?phpможет я что-то не так понял?
declare(strict_types=1);
class Test {
}
function countTests(Test &...$tests) {
return count($tests);
}
$tests = [];
for ($i = 0; $i < 100; $i++) {
$tests[] = new Test();
}
$begin = microtime(true);
for ($i = 0; $i < 100000; $i++) {
countTests(...$tests);
}
echo 'Time: ' . round(microtime(true) - $begin, 3) . "\n";
KN
KN
KN
F
F
KN
KN
function example(Test ...$x){}
примерно аналогична: function example(array $x)
{
foreach ($x as $y) {
assert($y instanceof Test);
}
}F
function example(Test ...$x){}
примерно аналогична: function example(array $x)
{
foreach ($x as $y) {
assert($y instanceof Test);
}
}KN
KN
KN
VS
KN