哪两个会更快

Which of the two will be faster and how can do such measurements

foreach ($posts as $post)
{
 $totalikes = count($post["Like"]);
 $totacomments = count($post["Comment"]);
 $max = ($totalikes < $totacomments )? $totacomments  : $totalikes;
 for($i=0;$i<$max;$i++)
 {
  if(isset($post["Like"][$i]))
   $users[] = $post["Like"][$i]["user_id"];
  if(isset($post["Comment"][$i]))
   $users[] = $post["Comment"][$i]["user_id"];
 }
}

or

foreach ($posts as $post)
{
 foreach ($post["Like"] as $like)
 {
  $users[] = $like["user_id"];
 }
 foreach ($post["Comment"] as $comment)
 {
  $users[] = $comment["user_id"];
 }
}

Which of the two is better

The second method.

First method will have overhead if the count of $post['like'] & $post['comment'] is different

PS: first method does not do the same thing as second method does ...

total loop in method A = 2 x max array size
total loop in method B = size of array A+size of array B

As for the $users, should be the same for both method