DEV Community

maddrid
maddrid

Posted on • Edited on

Cake\Collection\Collection vs Illuminate\Support\Collection

Any thoughts(benchmarks) on witch performs better (faster , lower memory usage ) ?

Any pro and cons on
Cake\Collection\Collection
vs
Illuminate\Support\Collection

Top comments (3)

Collapse
 
maddrid profile image
maddrid • Edited

Hey ! Did some tests , here is the results :
Filter 50 categories

Bench::start('get_categories_cake'); $buff = new \Cake\Collection\Collection($all); for ($i = 0; $i < 10000; $i++) { $ladies = $buff->filter(function ($category, $key) { return $category['pk_i_id'] === '22'; }); $get_cake = $ladies->toArray(); } Bench::stop('get_categories_cake'); d($get_cake); Bench::start('get_categories_laravel'); $collection = new Illuminate\Support\Collection($all); for ($i = 0; $i < 10000; $i++) { $filtered = $collection->filter(function ($value, $key) { return $value['pk_i_id'] === '22'; }); $get_laravel = $filtered->all(); } Bench::stop('get_categories_laravel'); d($get_laravel); 
Enter fullscreen mode Exit fullscreen mode

Results :

 [get_categories_cake] => Array ( [cpu_load] => Not enabled [duration] => 0.17000103 [memory] => 267.4 kb [peak] => 6.46 mb ) [get_categories_laravel] => Array ( [cpu_load] => Not enabled [duration] => 0.05999994 [memory] => 395.09 kb [peak] => 6.46 mb ) 
Enter fullscreen mode Exit fullscreen mode
Collapse
 
llagerlof profile image
Lawrence Lagerlof

Add the tag #help to this post.

Collapse
 
maddrid profile image
maddrid

Thanks !

Some comments may only be visible to logged-in visitors. Sign in to view all comments.