Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).
Version | System time (s) | User time (s) | Memory (MiB) |
---|---|---|---|
8.3.8 | 0.010 | 0.010 | 30.84 |
<?php
echo 'With class: ';
$start_time = microtime(TRUE);
class Data {
public $foo = 'example';
public $bar = 'example';
}
$data = new Data();
for ($i = 0; $i < 10000; $i++) {
$prop = 'foo';
$data->$prop; // access property but no echo, just to not polute the output;
}
$end_time = microtime(TRUE);
echo $end_time - $start_time . "\n";
echo "With array: ";
$start_time = microtime(TRUE);
$data = [
'foo' => 'example',
'bar' => 'example',
];
for ($i = 0; $i < 10000; $i++) {
$prop = 'foo';
$data[$prop]; // access key but no echo, just to not polute the output;
}
$end_time = microtime(TRUE);
echo $end_time - $start_time . "\n";
echo "With converted stdClass: ";
$start_time = microtime(TRUE);
$data = (object) [
'foo' => 'example',
'bar' => 'example',
];
for ($i = 0; $i < 10000; $i++) {
$prop = 'foo';
$data->$prop; // access propery but no echo, just to not polute the output;
}
$end_time = microtime(TRUE);
echo $end_time - $start_time;
Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).
Version | System time (s) | User time (s) | Memory (MiB) |
---|---|---|---|
8.3.8 | 0.010 | 0.010 | 30.84 |