User tests: Successful: Unsuccessful:
This is my first commit so sorry if it is not OK.
Pull Request for Issue # .
Replacing old code with the new one (just one line of code).
Category | ⇒ | Libraries |
Status | New | ⇒ | Pending |
@berserkerx can you please mark your test as successfully?
I have tested this item
Tested file names with or without extensions. OK.
Optimizing is really relative, pathinfo is much slower then the substr version.
strpos version about 0.016 seconds (by 10000 calls)
https://3v4l.org/OjlXi/perf#output
strpos version about 0.018-0.022 seconds (by 10000 calls)
https://3v4l.org/KvAmV/perf#output
PS: I know 3v4l is not a good benchmark tool but shows a direction.
Agree, PHP 7.1:
function getExt1 ($fileName) {
return ($pos = strrpos($fileName, '.')) !== false ? substr($fileName, $pos + 1) : '';
}
function getExt2 ($fileName) {
return (string) pathinfo($fileName, PATHINFO_EXTENSION);
}
$fileName = 'mod_subscription.php';
$s = microtime(true);
for ($i = 1000000; $i--; ) {
$fileExt = getExt2($fileName);
}
$time = microtime(true) - $s;
exit(var_dump($time));
Joomla's method: 3.26-3.21s
Pathinfo: 4.91-5.23s
ok
@vladimir179 does "ok" means a successfully Test?
@franz-wohlkoenig in my opinion this PR doesn't makes any sense because it slows down Joomla without any benefit.
@HLeithner thanks for Info. Callling @mbabker or @wilsonge if this PR should be closed.
If the difference is a second per million files I'm not sure it's a problem to be honest. When you're at the point of manipulating a million files a second here or there is going to be next to nothing
If this Issue get no different Response, it will be closed at 26th November 2017.
Does it really makes sense to reduce the speed of the core cms? Doing many of these changes would slow down the overall performance of the cms with no real benefit.
The running code is well tested and is faster then php native code. Even if this commit has a small speed impact, we should check every commit for performance improvements to get a better CMS.
But I'm happy with the decision by @mbabker what ever it is.
If the method were legitimately being used 10K+ times in a request cycle, we might consider leaving it alone and closing this. I would guess though it sees less than 10 uses in a request cycle when it actually does get called up, so at this point we're talking about a performance degradation of 1 or 2 milliseconds per method call. It can be made up for in other ways IMO.
Think of a Site 1000 requests per second
Status | Pending | ⇒ | Needs Review |
Maintainers please decide, Status is set on "Needs Review".
As a side effect, this fixes a bug we currently have when path contains period but file does not. So we're going to need something like this. On PHP 7+ pathinfo()
seems much slower than string manipulation.
Status | Needs Review | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2020-09-25 08:19:49 |
Closed_By | ⇒ | HLeithner | |
Labels |
Added:
Conflicting Files
?
|
Checked PHP source: pathinfo behavior is stable and it's simpler, than manual code.