- microtime: documentation ( source)
- trim: documentation ( source)
- strtolower: documentation ( source)
<?php
$aShitLoadOfSpaces = ' ';
$headerName = 'CONTENT-LENGTH';
$start = microtime(true);
for ($i = 0; $i < 500000; $i++) {
if (strtolower($headerName) === 'content-length') {}
}
$duration = microtime(true) - $start;
echo "strtolower: $duration\n";
$start = microtime(true);
for ($i = 0; $i < 500000; $i++) {
if ((($aShitLoadOfSpaces & $headerName) | $headerName) === 'content-length') {}
}
$duration = microtime(true) - $start;
echo "Bitwise 1: $duration\n";
$start = microtime(true);
for ($i = 0; $i < 500000; $i++) {
if (trim($aShitLoadOfSpaces | $headerName) === 'content-length') {}
}
$duration = microtime(true) - $start;
echo "Bitwise 2: $duration\n";