Bug #22158

Replace calls to t3lib_div:: within t3lib_div to self:: du to performance reasons

Added by Nikolas Hagelstein over 11 years ago. Updated almost 11 years ago.

Status:
Closed
Priority:
Should have
Assignee:
Category:
-
Target version:
-
Start date:
2010-02-22
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
PHP Version:
4.3
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

Currently t3lib_div uses t3lib_div:: to refere to itself statically.

Self:: is 8% to 10% faster than using classname:: due to the fact that no scope resolution has to be performed.

See:
http://svn.php.net/viewvc/php/php-src/branches/PHP_5_2/Zend/zend_API.c?view=markup

Line(2154 to 2164).

Minitest:
class Test {
public static function a() {
Test::c();
}

public static function b() {
self::c();
}
static function c() {
$a = 1;
}
}

$interation = 100000;

$timeStart = microtime();
for ($i = 1; $i <= $interation; $i++) {
Test::a();
}
$timeEnd = microtime();
$time = $timeEnd - $timeStart;
echo $time . ' seconds -> ' . $interation . 'x Test::c <br />';

$timeStart = microtime();
for ($i = 1; $i <= $interation; $i++) {
Test::b();
}
$timeEnd = microtime();
$time = $timeEnd - $timeStart;
echo $time . ' seconds -> ' . $interation . 'x self::c <br />';
?>
(issue imported from #M13611)


Files

t3lib_div-self.patch (63.5 KB) t3lib_div-self.patch Administrator Admin, 2010-02-22 16:28
#1

Updated by Benni Mack over 11 years ago

I had the same change in mind (and on my list). Glad you took care of it.

Could you send the patch to the core list? Thanks.

#2

Updated by Benni Mack over 11 years ago

Committed to trunk (rev. 7043).
Committed to TYPO3_4-3 (rev. 7044) (I got the OK from Olly)

Also available in: Atom PDF