[php-src] Issue #8283: Performance: array_reduce is drastically slower (~1000x) than implementing the same logic with foreach

From: Date: Wed, 30 Mar 2022 22:14:38 +0000
Subject: [php-src] Issue #8283: Performance: array_reduce is drastically slower (~1000x) than implementing the same logic with foreach
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-240588@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/8283 Comment Author: kamil-tekiela >I suppose if that's not possible, a warning in the documentation noting that there can be >serious performance implications to using array_reduce on larger (1000+ item) arrays and to inline >the logic for best results would do. I don't think that is necessary. Also, as @iluuu1994 pointed out the issue is present even without functions. The function overhead is rather small in this example. The most time is spent on recreating the array every time the function is called and it's not an issue of array_reduce. Doing the same in a loop will take just as long.

« previous php.bugs (#240588) next »