oop - Is there any benefit from explicitly defining all used classes and namespaces at the beggining of PHP class? -


consider these 2 classes:

namespace foo\bar;  use logicexception; use memcached;  class baz extends memcached {     public function testbaz()     {         throw new logicexception('not implemented');     } } 

the same class written as:

namespace foo\bar;  class baz2 extends \memcached {     public function testbaz()     {         throw new \logicexception('not implemented');     } } 

is there diffrence in performance of these 2 classes? if use composer's optimized autoloading?

also consider these 2 classes:

namespace foo\bar;  use acme\demo;  class kaz {     public function init(demo\unita $unita, demo\unitb $unitb)     {         //     } } 

the same coded as:

namespace foo\bar;  use acme\demo\unita; use acme\demo\unitb;  class kaz2 {     public function init(unita $unita, unitb $unitb)     {         //     } } 

and again same questions: there performance diffrence between two? if use composers optimized autoloading?

to clarify questions: there performance change?

i know use for, how alias class names etc. wondered iof there performance hit useing one/or other method.

use operator imports external qualified name or gives alias in namespace. classes loaded when use them, not on import. not make difference on autoloading.

but using shorter class names in code benefit, use whenever want.

update

importing performed @ compile-time there should not difference in performance if using kind of opcode cache apc or opcache (even if not using should insignificant change not use use operator).

btw if have concerns performance of code best thing use profilers. there many of them xdebug, blackfire. prefer use xhprof.


Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -