3v4l.org

run code in 300+ PHP versions simultaneously
<?php class inConstruct { function __construct($array) { foreach ($array as $key => $value) { if ($key == 100) { echo "Done"; } } } } class inMethod { function __construct($array) { $this->doThat($array); } function doThat($array){ foreach ($array as $key => $value) { if ($key == 100) { echo "Done"; } } } } $questions = range("a", "z", 1); for($i=0;$i<10;$i++) {} $start = microtime(); ## For inMethod for ($i=0; $i < 1000; $i++) { $m = new inConstruct($questions); unset($m); } echo (microtime() - $start); echo "\n"; $start = microtime(); ## For inConstruct for ($i=0; $i < 1000; $i++) { $m = new inMethod($questions); unset($m); } echo (microtime() - $start);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
2 jumps found. (Code = 44) Position 1 = 11, Position 2 = 8
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
2 jumps found. (Code = 44) Position 1 = 24, Position 2 = 16
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 40
Branch analysis from position: 40
2 jumps found. (Code = 44) Position 1 = 42, Position 2 = 34
Branch analysis from position: 42
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 34
2 jumps found. (Code = 44) Position 1 = 42, Position 2 = 34
Branch analysis from position: 42
Branch analysis from position: 34
Branch analysis from position: 16
2 jumps found. (Code = 44) Position 1 = 24, Position 2 = 16
Branch analysis from position: 24
Branch analysis from position: 16
Branch analysis from position: 8
2 jumps found. (Code = 44) Position 1 = 11, Position 2 = 8
Branch analysis from position: 11
Branch analysis from position: 8
filename:       /in/iQDjn
function name:  (null)
number of ops:  47
compiled vars:  !0 = $questions, !1 = $i, !2 = $start, !3 = $m
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   INIT_FCALL                                               'range'
          1        SEND_VAL                                                 'a'
          2        SEND_VAL                                                 'z'
          3        SEND_VAL                                                 1
          4        DO_ICALL                                         $4      
          5        ASSIGN                                                   !0, $4
   31     6        ASSIGN                                                   !1, 0
          7      > JMP                                                      ->9
          8    >   PRE_INC                                                  !1
          9    >   IS_SMALLER                                               !1, 10
         10      > JMPNZ                                                    ~8, ->8
   33    11    >   INIT_FCALL                                               'microtime'
         12        DO_ICALL                                         $9      
         13        ASSIGN                                                   !2, $9
   36    14        ASSIGN                                                   !1, 0
         15      > JMP                                                      ->22
   37    16    >   NEW                                              $12     'inConstruct'
         17        SEND_VAR_EX                                              !0
         18        DO_FCALL                                      0          
         19        ASSIGN                                                   !3, $12
   38    20        UNSET_CV                                                 !3
   36    21        PRE_INC                                                  !1
         22    >   IS_SMALLER                                               !1, 1000
         23      > JMPNZ                                                    ~16, ->16
   41    24    >   INIT_FCALL                                               'microtime'
         25        DO_ICALL                                         $17     
         26        SUB                                              ~18     $17, !2
         27        ECHO                                                     ~18
   43    28        ECHO                                                     '%0A'
   45    29        INIT_FCALL                                               'microtime'
         30        DO_ICALL                                         $19     
         31        ASSIGN                                                   !2, $19
   49    32        ASSIGN                                                   !1, 0
         33      > JMP                                                      ->40
   50    34    >   NEW                                              $22     'inMethod'
         35        SEND_VAR_EX                                              !0
         36        DO_FCALL                                      0          
         37        ASSIGN                                                   !3, $22
   51    38        UNSET_CV                                                 !3
   49    39        PRE_INC                                                  !1
         40    >   IS_SMALLER                                               !1, 1000
         41      > JMPNZ                                                    ~26, ->34
   54    42    >   INIT_FCALL                                               'microtime'
         43        DO_ICALL                                         $27     
         44        SUB                                              ~28     $27, !2
         45        ECHO                                                     ~28
         46      > RETURN                                                   1

Class inConstruct:
Function __construct:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 8
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 8
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 7
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 7
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
filename:       /in/iQDjn
function name:  __construct
number of ops:  10
compiled vars:  !0 = $array, !1 = $value, !2 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
    6     1      > FE_RESET_R                                       $3      !0, ->8
          2    > > FE_FETCH_R                                       ~4      $3, !1, ->8
          3    >   ASSIGN                                                   !2, ~4
    7     4        IS_EQUAL                                                 !2, 100
          5      > JMPZ                                                     ~6, ->7
    8     6    >   ECHO                                                     'Done'
    6     7    > > JMP                                                      ->2
          8    >   FE_FREE                                                  $3
   11     9      > RETURN                                                   null

End of function __construct

End of class inConstruct.

Class inMethod:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/iQDjn
function name:  __construct
number of ops:  5
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV                                             !0      
   17     1        INIT_METHOD_CALL                                         'doThat'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0          
   18     4      > RETURN                                                   null

End of function __construct

Function dothat:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 8
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 8
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 7
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 7
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
filename:       /in/iQDjn
function name:  doThat
number of ops:  10
compiled vars:  !0 = $array, !1 = $value, !2 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   RECV                                             !0      
   21     1      > FE_RESET_R                                       $3      !0, ->8
          2    > > FE_FETCH_R                                       ~4      $3, !1, ->8
          3    >   ASSIGN                                                   !2, ~4
   22     4        IS_EQUAL                                                 !2, 100
          5      > JMPZ                                                     ~6, ->7
   23     6    >   ECHO                                                     'Done'
   21     7    > > JMP                                                      ->2
          8    >   FE_FREE                                                  $3
   26     9      > RETURN                                                   null

End of function dothat

End of class inMethod.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
140.77 ms | 1409 KiB | 17 Q