script execution time during grouping
<pre><code>&lt;?php

$urls = array(
    'us/1',
    'us/2',
    'gb/1',
    'gb/2',
    'de/1',
    'de/2',
);

$current_country = '';
foreach ($urls as $url) {
    $sleep_sec = rand(1, 3);
    printf('Proccessed url &lt;b&gt;%s&lt;/b&gt; in %s sec%s', strtoupper($url), $sleep_sec, '&lt;br/&gt;');

    $country = substr($url, 0, 2);
    if ($current_country !== $country) {
        $start_at = microtime(true);
        $end_at = microtime(true) - $start_at;

        $logs[] = sprintf('Proccessed country &lt;b&gt;%s&lt;/b&gt; in %s sec', strtoupper($country), $end_at);
    }
    $current_country = $country;

    sleep($sleep_sec);
}

echo str_repeat('&lt;br&gt;', 2);

foreach($logs as $log) {
    echo $log;
    echo '&lt;br&gt;';
}
</code></pre>

<p><strong>Now result is:</strong></p>

<p>Proccessed url <strong>US/1</strong> in 2 sec <br>
Proccessed url <strong>US/2</strong> in 2 sec <br>
Proccessed url <strong>GB/1</strong> in 1 sec <br>
Proccessed url <strong>GB/2</strong> in 2 sec <br>
Proccessed url <strong>DE/1</strong> in 3 sec <br>
Proccessed url <strong>DE/2</strong> in 2 sec <br>
<br>
Proccessed country <strong>US</strong> in 1.9073486328125E-6 sec<br>
Proccessed country <strong>GB</strong> in 2.1457672119141E-6 sec<br>
Proccessed country <strong>DE</strong> in 5.0067901611328E-6 sec</p>

<p><strong>Expected result:</strong></p>

<p>Proccessed country <strong>US</strong> in 4 sec<br>
Proccessed country <strong>GB</strong> in 3 sec<br>
Proccessed country <strong>DE</strong> in 5 sec</p>

<p>How to count correct execution time for each country ?</p>
