Conflicting Files ? ?

Pending

User tests: Successful: Unsuccessful:

avatar foxo79
foxo79
21 Sep 2017

This is my first commit so sorry if it is not OK.

Pull Request for Issue # .

Summary of Changes

Replacing old code with the new one (just one line of code).

Testing Instructions

Expected result

Actual result

Documentation Changes Required

Votes

# of Users Experiencing Issue
0/1
Average Importance Score
5.00

avatar joomla-cms-bot joomla-cms-bot - change - 21 Sep 2017
Category Libraries
avatar foxo79 foxo79 - open - 21 Sep 2017
avatar foxo79 foxo79 - change - 21 Sep 2017
Status New Pending
avatar ethernidee
ethernidee - comment - 21 Sep 2017

Checked PHP source: pathinfo behavior is stable and it's simpler, than manual code.

avatar franz-wohlkoenig
franz-wohlkoenig - comment - 21 Sep 2017

@berserkerx can you please mark your test as successfully?

avatar berserkerx berserkerx - test_item - 21 Sep 2017 - Tested successfully
avatar ethernidee
ethernidee - comment - 21 Sep 2017

I have tested this item successfully on dee42df

Tested file names with or without extensions. OK.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/18030.

avatar HLeithner
HLeithner - comment - 23 Sep 2017

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.

avatar ethernidee
ethernidee - comment - 23 Sep 2017

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

avatar vladimir179
vladimir179 - comment - 25 Sep 2017

ok


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/18030.

avatar franz-wohlkoenig
franz-wohlkoenig - comment - 26 Oct 2017

@vladimir179 does "ok" means a successfully Test?


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/18030.

avatar HLeithner
HLeithner - comment - 28 Oct 2017

@franz-wohlkoenig in my opinion this PR doesn't makes any sense because it slows down Joomla without any benefit.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/18030.

avatar franz-wohlkoenig
franz-wohlkoenig - comment - 28 Oct 2017

@HLeithner thanks for Info. Callling @mbabker or @wilsonge if this PR should be closed.

avatar wilsonge
wilsonge - comment - 29 Oct 2017

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

avatar franz-wohlkoenig
franz-wohlkoenig - comment - 29 Oct 2017

If this Issue get no different Response, it will be closed at 26th November 2017.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/18030.

avatar wilsonge
wilsonge - comment - 29 Oct 2017

To clarify above I think that we should merge this unless @mbabker feels differently

avatar HLeithner
HLeithner - comment - 29 Oct 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.

avatar mbabker
mbabker - comment - 29 Oct 2017

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.

avatar HLeithner
HLeithner - comment - 29 Oct 2017

Think of a Site 1000 requests per second

avatar franz-wohlkoenig franz-wohlkoenig - change - 26 Nov 2017
Status Pending Needs Review
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 26 Nov 2017

Maintainers please decide, Status is set on "Needs Review".


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/18030.

avatar SharkyKZ
SharkyKZ - comment - 14 Sep 2020

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.

avatar HLeithner
HLeithner - comment - 25 Sep 2020

Alternative PR #30646 has been merged. Closing this. thanks for your time creating this PR.

avatar HLeithner HLeithner - close - 25 Sep 2020
avatar HLeithner HLeithner - change - 25 Sep 2020
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 ?

Add a Comment

Login with GitHub to post a comment