. MacOS , insertnamehere:
1.8200218677521
2.4083371162415
. , , . , ?
$find = array('/_{2,}/', '/-{2,}/');
$replace = array('_', '-');
$s_3 = microtime(true);
for ($i = 0; $i < 1000000; ++$i) {
$r_1 = preg_replace( $find, $replace, $value);
}
$e_3 = microtime(true);
1.7364799976349
2.4450128078461
1.5605390071869
, . .
It is important to note that if you simply reload the page several times, the coincidence rates of the two arrays tend to converge until there is a slight difference. Presumably, this is PHP caching of a compiled script - a little editing and saving it again gives more divergent values.
So, there is another benchmark for production environment - how do the values change over time in a real scenario?
source
share