<?php
$str = str_repeat('a', 1e4);
$start = microtime(true);
$pos = 0;
while(preg_match('/\G\w/', $str, $m, 0, $pos)) ++$pos;
$end = microtime(true);
echo 'NO u flag: ', number_format(($end - $start)*1000, 6), 'ms', PHP_EOL;
$str = str_repeat('e', 1e4);
$start = microtime(true);
$pos = 0;
while(preg_match('/\G\w/u', $str, $m, 0, $pos)) ++$pos;
$end = microtime(true);
echo 'WITH u flag: ', number_format(($end - $start)*1000, 6), 'ms', PHP_EOL;
preferences:
25.28 ms | 407 KiB | 5 Q