@ 2013-05-04T11:38:08Z <?php
$count = 100;
$start = microtime(true);
for ($i = 0; $i < $count; $i++) {
$str = "abc";
$str = preg_replace_callback('/a/', 'strtoupper', $str);
$str = preg_replace_callback('/b/', 'strtoupper', $str);
$str = preg_replace_callback('/c/', 'strtoupper', $str);
$str = preg_replace_callback('/a/', 'strtolower', $str);
$str = preg_replace_callback('/b/', 'strtolower', $str);
$str = preg_replace_callback('/c/', 'strtolower', $str);
}
echo "Completed in " . (microtime(true) - $start) . " Seconds\n";
$start = microtime(true);
for ($i = 0; $i < $count; $i++) {
$str = "abc";
$str = preg_replace(array(
'/a/e',
'/b/e',
'/c/e',
'/a/e',
'/b/e',
'/c/e',
),
array(
'strtoupper(\'$1\')',
'strtoupper(\'$1\')',
'strtoupper(\'$1\')',
'strtolower(\'$1\')',
'strtolower(\'$1\')',
'strtolower(\'$1\')',
),
$str
);
}
echo "Completed in " . (microtime(true) - $start) . " Seconds\n";
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).
Version System time (s) User time (s) Memory (MiB) 7.2.10 0.120 0.006 14.96 7.2.9 0.141 0.006 14.45 7.2.8 0.104 0.008 14.93 7.2.7 0.151 0.006 15.34 7.2.6 0.032 0.003 15.21 7.2.5 0.095 0.006 15.27 7.2.4 0.098 0.009 14.92 7.1.22 0.119 0.015 13.73 7.1.21 0.140 0.016 14.15 7.1.20 0.154 0.000 13.78 7.1.19 0.205 0.010 13.96 7.1.18 0.090 0.010 13.68 7.1.17 0.091 0.003 13.98 7.1.16 0.066 0.010 14.03 7.0.31 0.112 0.010 13.50 7.0.30 0.025 0.011 13.57 7.0.29 0.089 0.010 13.83 5.6.38 0.008 0.015 14.45 5.6.37 0.011 0.011 14.43 5.6.36 0.014 0.011 14.56
preferences:dark mode live preview
33.5 ms | 401 KiB | 5 Q