I have the following test class:
Code: Select all
$loopCount = 1024 * 512;
error_reporting(E_ALL);
class testClass
{
public $veryLongAttributeName0 = NULL;
public $veryLongAttributeName1 = NULL;
public $veryLongAttributeName2 = NULL;
public $veryLongAttributeName3 = NULL;
public $veryLongAttributeName4 = NULL;
public $veryLongAttributeName5 = NULL;
public $veryLongAttributeName6 = NULL;
public $veryLongAttributeName7 = NULL;
public $veryLongAttributeName8 = NULL;
public $veryLongAttributeName9 = NULL;
function __construct($libraryType = null, $fileID = null)
{
}
function _destructor()
{
} // function destructor
} // class testClass
$callStartTime = microtime(true);
$testArray = array();
for ($i = 0; $i < $loopCount; ++$i) {
$testArray[] = new testClass();
}
$callEndTime = microtime(true);
$callTime = $callEndTime - $callStartTime;
echo '<br />Call time to instantiate '.$loopCount.' objects of testClass was '.sprintf('%.4f',$callTime)." seconds<br />\n";
echo date('H:i:s').' Peak memory usage: '.(memory_get_peak_usage(true) / 1024 / 1024).' MB<br />';Code: Select all
Call time to instantiate 524288 objects of testClass was 3.4530 seconds
09:34:08 Peak memory usage: 494.75 MB
Code: Select all
public $veryLongAttributeName0 = NULL;
public $veryLongAttributeName1 = NULL;
public $veryLongAttributeName2 = NULL;
public $veryLongAttributeName3 = NULL;
public $veryLongAttributeName4 = NULL;
public $veryLongAttributeName5 = NULL;
public $veryLongAttributeName6 = NULL;
public $veryLongAttributeName7 = NULL;
public $veryLongAttributeName8 = NULL;
public $veryLongAttributeName9 = NULL;
Code: Select all
public $v0 = NULL;
public $v1 = NULL;
public $v2 = NULL;
public $v3 = NULL;
public $v4 = NULL;
public $v5 = NULL;
public $v6 = NULL;
public $v7 = NULL;
public $v8 = NULL;
public $v9 = NULL;
Code: Select all
Call time to instantiate 524288 objects of testClass was 3.2260 seconds
09:37:46 Peak memory usage: 374.75 MB
That shouldn't be right... should it? Even in a semi-compiled language such as PHP, the memory usage (and possibly speed of execution) shouldn't be affected by the length of an attribute name.