mysql - Can I paralellize this foreach loop in PHP? -
currently script takes 6 minutes complete.
here's snippet:
$items = getsomeitems(); $results = array(); foreach ($items $index => $value) { $valuea = getvaluea($value); // 2 minute process. $valueb = getvalueb($value); // 2 minute process. $valuec = getvaluec($value); // 2 minute process. $results[] = array('a' => $valuea, 'b' => $valueb, 'c' => $valuec, ) } return $results;
is there way paralellize foreach loop? don't care order in arrays added $results
, order them in sql anyways.
can like?
parallel-foreach ($items $index => $value) { $valuea = getvaluea($value); // 2 minute process. $valueb = getvalueb($value); // 2 minute process. $valuec = getvaluec($value); // 2 minute process. $results[] = array('a' => $valuea, 'b' => $valueb, 'c' => $valuec, ) }
c# has similar idea in parallel.foreach. i'm looking similar in php.
Comments
Post a Comment