[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:19:49 +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-240589@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/8283 Comment Author: Firehed Yes, let's disregard the function call thing as that turned out to be incorrect as @iluuu1994 pointed out. I think the end result on performance expectations that users would have (and I did) is the same. Reducing a large array into a smaller one (re-indexing, etc) is a very common use-case for array_reduce, and having an array for $carry causing a 1000x performance loss compared to foreach is extremely surprising.

« previous php.bugs (#240589) next »