Précédent   Forum des professionnels en informatique > PHP > Langage > Fonctions
Fonctions Forum d'entraide sur les fonctions PHP. Avant de poster -> FAQ fonctions et Sources diverses
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 12/10/2011, 20h58   #1
Nouveau Membre du Club
 
Inscription : juillet 2009
Messages : 110
Détails du profil
Informations forums :
Inscription : juillet 2009
Messages : 110
Points : 37
Points : 37
Par défaut Performance fonction static

Bonjour à tous,

je me pose une question sur les performances :

je sais qu'une fonction static dans une classe est exécuté 4 fois plus rapidement qu'une fonction d'une class qui n'est pas static.

Maintenant ma question: qu'est-ce qui est le mieux (en terme de performance) entre

a) une fonction static qui est dans une classe
Code :
1
2
3
4
5
6
7
8
Class Personne
{
public static function MaFonction()
 {
   // blabla
 }
}
Personne::MaFonction();
b) une fonction non static qui n'est pas dans une classe ?
Code :
1
2
3
4
5
6
 
 function MaFonction()
 {
   // blabla
 }
MaFonction();
gianni7033 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 13/10/2011, 00h00   #2
Modérateur
 
Inscription : septembre 2010
Messages : 7 131
Détails du profil
Informations forums :
Inscription : septembre 2010
Messages : 7 131
Points : 8 491
Points : 8 491
la réponse est dans ton sujet non ?
__________________
http://blog.stealth35.com/
stealth35 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 13/10/2011, 00h31   #3
Nouveau Membre du Club
 
Inscription : juillet 2009
Messages : 110
Détails du profil
Informations forums :
Inscription : juillet 2009
Messages : 110
Points : 37
Points : 37
non justement, car je prend d'abord l'exemple de 2 fonctions qui sont dans une class.

Hors ma question (le b) concernes une fonction qui n'est pas dans une class
gianni7033 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 13/10/2011, 00h56   #4
Modérateur
 
Inscription : septembre 2010
Messages : 7 131
Détails du profil
Informations forums :
Inscription : septembre 2010
Messages : 7 131
Points : 8 491
Points : 8 491
t'as une opération de plus en static

Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
Finding entry points
Branch analysis from position: 0
Return found
filename:       /Library/Server/Web/Data/Sites/Default/test/index.php
function name:  (null)
number of ops:  8
compiled vars:  none
line     # *  op                           fetch          ext  return  operands
---------------------------------------------------------------------------------
   3     0  >   EXT_STMT                                                 
         1      NOP                                                      
   9     2      EXT_STMT                                                 
         3      ZEND_INIT_STATIC_METHOD_CALL                             'Personne', 'MaFonction'
         4      EXT_FCALL_BEGIN                                          
         5      DO_FCALL_BY_NAME                              0          
         6      EXT_FCALL_END                                            
         7    > RETURN                                                   1
 
branch: #  0; line:     3-    9; sop:     0; eop:     7
path #1: 0, 
Class Personne:
Function mafonction:
Finding entry points
Branch analysis from position: 0
Return found
filename:       /Library/Server/Web/Data/Sites/Default/test/index.php
function name:  MaFonction
number of ops:  3
compiled vars:  none
line     # *  op                           fetch          ext  return  operands
---------------------------------------------------------------------------------
   4     0  >   EXT_NOP                                                  
   7     1      EXT_STMT                                                 
         2    > RETURN                                                   null
 
branch: #  0; line:     4-    7; sop:     0; eop:     2
path #1: 0, 
End of function mafonction.
 
End of class Personne.
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
Finding entry points
Branch analysis from position: 0
Return found
filename:       /Library/Server/Web/Data/Sites/Default/test/index.php
function name:  (null)
number of ops:  7
compiled vars:  none
line     # *  op                           fetch          ext  return  operands
---------------------------------------------------------------------------------
   2     0  >   EXT_STMT                                                 
         1      NOP                                                      
   6     2      EXT_STMT                                                 
         3      EXT_FCALL_BEGIN                                          
         4      DO_FCALL                                      0          'mafonction'
         5      EXT_FCALL_END                                            
         6    > RETURN                                                   1
 
branch: #  0; line:     2-    6; sop:     0; eop:     6
path #1: 0, 
Function mafonction:
Finding entry points
Branch analysis from position: 0
Return found
filename:       /Library/Server/Web/Data/Sites/Default/test/index.php
function name:  MaFonction
number of ops:  3
compiled vars:  none
line     # *  op                           fetch          ext  return  operands
---------------------------------------------------------------------------------
   2     0  >   EXT_NOP                                                  
   5     1      EXT_STMT                                                 
         2    > RETURN                                                   null
 
branch: #  0; line:     2-    5; sop:     0; eop:     2
path #1: 0, 
End of function mafonction.
__________________
http://blog.stealth35.com/
stealth35 est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 04h52.


 
 
 
 
Partenaires

Hébergement Web