Em termos de performance, para embasar meu achismo (peço desculpas por não usar o pastbin, mas não tenho acesso de onde estou), com o uso de vários requires, mesmo sendo once, o tempo é praticamente o dobro para cada comparação:
RESULTADO CODIGO #1
1 = Did nothing in 0.00031495094299316 seconds
10 = Did nothing in 0.00061702728271484 seconds
100 = Did nothing in 0.0051381587982178 seconds
1000 = Did nothing in 0.047922849655151 seconds
10000 = Did nothing in 0.47959589958191 seconds
100000 = Did nothing in 4.8598599433899 seconds
RESULTADO CODIGO #2
1 = Did nothing in 0.00011610984802246 seconds
10 = Did nothing in 0.00030708312988281 seconds
100 = Did nothing in 0.0025839805603027 seconds
1000 = Did nothing in 0.025318145751953 seconds
10000 = Did nothing in 0.24161100387573 seconds
100000 = Did nothing in 2.4257280826569 seconds
# -- codigo 1
<?php
function microtime_float()
{
list($usec, $sec) = explode(" ", microtime());
return ((float)$usec + (float)$sec);
}
$time_start = microtime_float();
for ($i = 0; $i < 1; $i++) {
require_once './lote/CL0.php';
require_once './lote/CL1.php';
require_once './lote/CL2.php';
require_once './lote/CL3.php';
require_once './lote/CL4.php';
require_once './lote/CL5.php';
require_once './lote/CL6.php';
require_once './lote/CL7.php';
require_once './lote/CL8.php';
require_once './lote/CL9.php';
require_once './lote/CL10.php';
require_once './lote/CL11.php';
require_once './lote/CL12.php';
require_once './lote/CL13.php';
require_once './lote/CL14.php';
require_once './lote/CL15.php';
require_once './lote/CL16.php';
require_once './lote/CL17.php';
require_once './lote/CL18.php';
require_once './lote/CL19.php';
$instance0 = new CL0;
$instance1 = new CL1;
$instance2 = new CL2;
$instance3 = new CL3;
$instance4 = new CL4;
$instance5 = new CL5;
$instance6 = new CL6;
$instance7 = new CL7;
$instance8 = new CL8;
$instance9 = new CL9;
$instance10 = new CL10;
$instance11 = new CL11;
$instance12 = new CL12;
$instance13 = new CL13;
$instance14 = new CL14;
$instance15 = new CL15;
$instance16 = new CL16;
$instance17 = new CL17;
$instance18 = new CL18;
$instance19 = new CL19;
for ($j = 0; $j < 20; $j++) {
$instance = 'instance' . $j;
//echo $$instance; die;
$$instance->m0();
}
}
$time_end = microtime_float();
$time = $time_end - $time_start;
echo "Did nothing in $time seconds\n";
código #código #2
<?php
function microtime_float()
{
list($usec, $sec) = explode(" ", microtime());
return ((float)$usec + (float)$sec);
}
$time_start = microtime_float();
for ($i = 0; $i < 100000; $i++) {
require_once './benchmark/CL1.php';
$instance = new CL1;
for ($j = 0; $j < 20; $j++) {
$method = 'm' . $j;
$instance->$method();
}
}
$time_end = microtime_float();
$time = $time_end - $time_start;
echo "Did nothing in $time seconds\n";
2
<?php
function microtime_float()
{
list($usec, $sec) = explode(" ", microtime());
return ((float)$usec + (float)$sec);
}
$time_start = microtime_float();
for ($i = 0; $i < 100000; $i++) {
require_once './benchmark/CL1.php';
$instance = new CL1;
for ($j = 0; $j < 20; $j++) {
$method = 'm' . $j;
$instance->$method();
}
}
$time_end = microtime_float();
$time = $time_end - $time_start;
echo "Did nothing in $time seconds\n";