As the example document indicates, this can actually affect Aeva so we do need to look into it, for cases where the file cache is used.
SMF bug 4956 (slash in cache key causes cache to fail)
« on February 29th, 2012, 02:17 PM »
This topic was marked solved by its starter, on December 14th, 2012, 01:23 AM
Carrying out 500000 iterations
String: `something short`
MD5: 0.62707901000977 seconds
SHA1: 0.62861299514771 seconds
B64: 0.44805788993835 seconds
B64/sstrtr: 1.0246500968933 seconds
B64/str_replace: 1.4543380737305 seconds
String: `something much much much much much longer that we can use to benchmark these things.`
MD5: 0.67529892921448 seconds
SHA1: 0.75934195518494 seconds
B64: 0.47315502166748 seconds
B64/sstrtr: 1.0639209747314 seconds
B64/str_replace: 1.5031769275665 seconds
String: `something impossibly and unrealistically long, after longer than the typical cache key will be but just in case it is worth having an idea of relative performance`
MD5: 0.74138998985291 seconds
SHA1: 0.8517210483551 seconds
B64: 0.50031614303589 seconds
B64/sstrtr: 1.154757976532 seconds
B64/str_replace: 1.6336131095886 seconds
<?php
$strings = array(
'something short',
'something much much much much much longer that we can use to benchmark these things.',
'something impossibly and unrealistically long, after longer than the typical cache key will be but just in case it is worth having an idea of relative performance',
);
$iters = 500000;
echo 'Carrying out ', $iters, ' iterations<br>';
foreach ($strings as $str)
{
echo '<hr><br>String: `', $str, '`<br>';
$time_start = microtime(true);
for ($i = 0; $i < $iters; $i++)
$dummy = md5($str);
$time_end = microtime(true);
echo ' MD5: ', $time_end - $time_start, ' seconds<br>';
$time_start = microtime(true);
for ($i = 0; $i < $iters; $i++)
$dummy = sha1($str);
$time_end = microtime(true);
echo ' SHA1: ', $time_end - $time_start, ' seconds<br>';
$time_start = microtime(true);
for ($i = 0; $i < $iters; $i++)
$dummy = base64_encode($str);
$time_end = microtime(true);
echo ' B64: ', $time_end - $time_start, ' seconds<br>';
$time_start = microtime(true);
for ($i = 0; $i < $iters; $i++)
$dummy = strtr(base64_encode($str), '+/=', '-__');
$time_end = microtime(true);
echo ' B64/sstrtr: ', $time_end - $time_start, ' seconds<br>';
$time_start = microtime(true);
$s = array('+', '/', '=');
$r = array('-', '_', '_');
for ($i = 0; $i < $iters; $i++)
$dummy = str_replace($s, $r, base64_encode($str));
$time_end = microtime(true);
echo ' B64/str_replace: ', $time_end - $time_start, ' seconds<br>';
}