- microtime: documentation ( source)
- preg_replace: documentation ( source)
- number_format: documentation ( source)
<?php
$i=0;
$time = microtime(true);
while($i < 5000)
{
$i++;
preg_replace('/(^|[a-z])([A-Z])/e', 'strtolower(strlen("\\1") ? "\\1_\\2" : "\\2")', 'VeryLongClassName');
}
$time = microtime(true) - $time;
echo '1: ' . number_format($time, 3) ."\n";
$i=0;
$time = microtime(true);
while($i < 5000)
{
$i++;
preg_replace('/(?!^)[[:upper:]][[:lower:]]/', '$0', preg_replace('/(?!^)[[:upper:]]+/', '_'.'$0', 'VeryLongClassName'));
}
$time = microtime(true) - $time;
echo '2: ' . number_format($time, 3) ."\n";