[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:09:07 +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-240587@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/8283 Comment Author: Firehed Noted @kamil-tekiela - I was about to update the issue regarding the function call and saw your reply indicating the same. "Bug" may not be the best description here, but it was the closest issue template for me to work from. As far as end-user semantics, I don't think function calls being involved change _expectations_ around performance here, although it clearly explains the _source_ of them. Ideally, there could be some sort of performance optimizations that occur within the array_reduce source (perhaps finding a way to inline the function and avoiding the calling overhead for every item?). But 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.

« previous php.bugs (#240587) next »