Search posts, tags, users, and pages
So just to understand the numbers correct. You say that arrays are more efficient than the other 2?
yes, the numbers suggest it's faster an more memory efficient at php7.2 i still have to analyze it further.
I wouldn't be surprised for that conclusion. Dare to take the Laravel Collection into the equation as well? laravel.com/api/5.8/Illuminate/Support/Collection… It's very widely used in the PHP community nowadays as a substitute for Arrays - well it's arrays under the hood, so probably close to arrays but a bit slower I would expect.
collect([array])->each(function ($item) {
// $item in the array
});
i can just by looking at the source say: most likely yes. It will be slower, they don't use a generator system so the memory footprint will add up as well :) but I will check the facts before I assume to much :)
Emil Moe it is in the same range as a data object. with utilizing arrays to store.
$objectStorage = [];
for ($i = 0; $i < 10000000; $i++) {
$objectStorage[] = new Collection([1, 200, 40]);
}
it has around 100MB more but that's not that bad. And about my mentioned generator approach I tested it, it's even worse memory wise. But this is a mean test because it tests the impact of the amount of structures and not the impact of the amount of data.
We could make it faster since laravel is really slow in comparison and the vld analyzis is huge. But this would most likely will happen with all frameworks. We don't pick them because they are efficient ;D but because there could be worse and we can work more efficient.
Haha true. They created "Lumen" which is a variant for API that should be faster, and no one forces you to use Collections, so I guess that's the answer there.