@ 2024-09-25T04:48:59Z <?php
function getBaseURLPath() {
return 'https://example.com/sub-directory/';
}
function getBaseURLPathOnly() {
return '/';
}
function buildWithBaseURLPathOld($info, $baseURLPath)
{
$result = '';
if (!empty($baseURLPath)) {
$result = $baseURLPath;
if (!empty($info)) {
$path = explode('/', $info);
// Remove base path from the path info.
$extractedInfo = array_pop($path);
if (!empty($extractedInfo)) {
$result .= $extractedInfo;
}
}
}
return $result;
}
function buildWithBaseURLPathNew($info, $baseURLPath)
{
$result = '';
if (!empty($baseURLPath)) {
$result = $baseURLPath;
if (!empty($info)) {
// Remove base path from the path info.
$extractedInfo = str_replace($baseURLPath, '', $info);
// Remove starting and ending slash.
$extractedInfo = trim($extractedInfo, '/');
if (!empty($extractedInfo)) {
$result .= $extractedInfo;
}
}
}
return $result;
}
echo "Old: " . buildWithBaseURLPathOld('saml/acs',getBaseURLPath()) . PHP_EOL;
echo "New: " . buildWithBaseURLPathNew('saml/acs',getBaseURLPath()) . PHP_EOL;
echo "Old: " . buildWithBaseURLPathOld('/saml/acs',getBaseURLPath()) . PHP_EOL;
echo "New: " . buildWithBaseURLPathNew('/saml/acs',getBaseURLPath()) . PHP_EOL;
echo "Old: " . buildWithBaseURLPathOld('/',getBaseURLPath()) . PHP_EOL;
echo "New: " . buildWithBaseURLPathNew('/',getBaseURLPath()) . PHP_EOL;
echo "Old: " . buildWithBaseURLPathOld('',getBaseURLPath()) . PHP_EOL;
echo "New: " . buildWithBaseURLPathNew('',getBaseURLPath()) . PHP_EOL;
// Case not considered where URL is not a URL...
echo "Old: " . buildWithBaseURLPathOld('saml/acs',getBaseURLPathOnly()) . PHP_EOL;
echo "New: " . buildWithBaseURLPathNew('saml/acs',getBaseURLPathOnly()) . PHP_EOL;
echo "Old: " . buildWithBaseURLPathOld('/saml/acs',getBaseURLPathOnly()) . PHP_EOL;
echo "New: " . buildWithBaseURLPathNew('/saml/acs',getBaseURLPathOnly()) . PHP_EOL;
echo "Old: " . buildWithBaseURLPathOld('/',getBaseURLPathOnly()) . PHP_EOL;
echo "New: " . buildWithBaseURLPathNew('/',getBaseURLPathOnly()) . PHP_EOL;
echo "Old: " . buildWithBaseURLPathOld('',getBaseURLPathOnly()) . PHP_EOL;
echo "New: " . buildWithBaseURLPathNew('',getBaseURLPathOnly()) . PHP_EOL;
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) 8.3.12 0.010 0.000 19.04 8.3.11 0.016 0.004 16.59 8.3.10 0.027 0.006 16.38 8.3.9 0.023 0.004 16.80 8.3.8 0.019 0.019 16.67 8.3.7 0.035 0.004 16.55 8.3.6 0.019 0.011 16.53 8.3.5 0.028 0.010 16.71 8.3.4 0.018 0.011 17.45 8.3.3 0.016 0.008 17.46 8.3.2 0.025 0.006 17.39 8.3.1 0.020 0.004 17.50 8.3.0 0.007 0.003 17.52 8.2.24 0.008 0.000 16.37 8.2.23 0.014 0.007 16.51 8.2.22 0.019 0.000 16.34 8.2.21 0.016 0.006 16.68 8.2.20 0.014 0.007 16.54 8.2.19 0.015 0.006 16.39 8.2.18 0.016 0.006 16.48 8.2.17 0.014 0.007 17.71 8.2.16 0.016 0.004 17.69 8.2.15 0.017 0.003 17.57 8.2.14 0.013 0.005 17.53 8.2.13 0.019 0.005 17.73 8.2.12 0.019 0.000 17.52 8.2.11 0.014 0.006 17.58 8.2.10 0.021 0.004 17.59 8.2.9 0.020 0.007 17.58 8.2.8 0.035 0.007 17.60 8.2.7 0.023 0.003 17.67 8.2.6 0.023 0.000 17.55 8.2.5 0.025 0.011 17.62 8.2.4 0.029 0.005 17.39 8.2.3 0.016 0.006 17.68 8.2.2 0.025 0.000 17.48 8.2.1 0.015 0.006 17.52 8.2.0 0.017 0.000 17.49 8.1.30 0.007 0.011 16.31 8.1.29 0.012 0.008 16.18 8.1.28 0.018 0.000 16.21 8.1.27 0.019 0.003 17.13 8.1.26 0.024 0.000 17.40 8.1.25 0.025 0.000 17.20 8.1.24 0.010 0.013 17.35 8.1.23 0.017 0.000 17.43 8.1.22 0.014 0.007 17.07 8.1.21 0.013 0.003 17.19 8.1.20 0.019 0.000 17.00 8.1.19 0.013 0.008 17.17 8.1.18 0.015 0.006 17.26 8.1.17 0.012 0.005 17.25 8.1.16 0.017 0.004 17.04 8.1.15 0.018 0.002 17.12 8.1.14 0.016 0.003 17.15 8.1.13 0.015 0.004 16.97 8.1.12 0.019 0.004 17.20 8.1.11 0.009 0.009 17.13 8.1.10 0.020 0.000 17.43 8.1.9 0.016 0.003 16.91 8.1.8 0.016 0.005 17.27 8.1.7 0.010 0.007 16.98 8.1.6 0.010 0.010 17.16 8.1.5 0.016 0.004 17.08 8.1.4 0.016 0.003 17.36 8.1.3 0.015 0.004 17.41 8.1.2 0.018 0.000 17.21 8.1.1 0.013 0.006 17.29 8.1.0 0.014 0.005 17.08
preferences:dark mode live preview
36.35 ms | 403 KiB | 5 Q