3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Test { protected $a; public function getA() { return $this->a; } public function setA($a) { $this->a = $a; } } $test = new Test; $test->setA("foo"); $start_time = MICROTIME(TRUE); for ($i=1; $i<=10000; $i++) { if ('' !== ($foo = $test->getA())) { echo $foo; } } $stop_time = MICROTIME(TRUE); $time = $stop_time - $start_time; PRINT "Elapsed time was $time seconds."; $start_time2 = MICROTIME(TRUE); for ($i=1; $i<=10000; $i++) { if ('' !== ($foo = $test->getA())) { echo $foo; } unset($foo); } $stop_time2 = MICROTIME(TRUE); $time2 = $stop_time2 - $start_time2; PRINT "Elapsed time was $time2 seconds."; $start_time3 = MICROTIME(TRUE); for ($i=1; $i<=10000; $i++) { if ('' !== $test->getA()) { echo $test->getA(); } } $stop_time3 = MICROTIME(TRUE); $time3 = $stop_time3 - $start_time3; PRINT "Elapsed time was $time3 seconds.";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
2 jumps found. (Code = 44) Position 1 = 21, Position 2 = 12
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 45
Branch analysis from position: 45
2 jumps found. (Code = 44) Position 1 = 47, Position 2 = 37
Branch analysis from position: 47
1 jumps found. (Code = 42) Position 1 = 71
Branch analysis from position: 71
2 jumps found. (Code = 44) Position 1 = 73, Position 2 = 63
Branch analysis from position: 73
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 63
2 jumps found. (Code = 43) Position 1 = 67, Position 2 = 70
Branch analysis from position: 67
2 jumps found. (Code = 44) Position 1 = 73, Position 2 = 63
Branch analysis from position: 73
Branch analysis from position: 63
Branch analysis from position: 70
Branch analysis from position: 37
2 jumps found. (Code = 43) Position 1 = 42, Position 2 = 43
Branch analysis from position: 42
2 jumps found. (Code = 44) Position 1 = 47, Position 2 = 37
Branch analysis from position: 47
Branch analysis from position: 37
Branch analysis from position: 43
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 18
Branch analysis from position: 17
2 jumps found. (Code = 44) Position 1 = 21, Position 2 = 12
Branch analysis from position: 21
Branch analysis from position: 12
Branch analysis from position: 18
filename:       /in/X37Wo
function name:  (null)
number of ops:  84
compiled vars:  !0 = $test, !1 = $start_time, !2 = $i, !3 = $foo, !4 = $stop_time, !5 = $time, !6 = $start_time2, !7 = $stop_time2, !8 = $time2, !9 = $start_time3, !10 = $stop_time3, !11 = $time3
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   NEW                                              $12     'Test'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $12
   10     3        INIT_METHOD_CALL                                         !0, 'setA'
          4        SEND_VAL_EX                                              'foo'
          5        DO_FCALL                                      0          
   12     6        INIT_FCALL                                               'microtime'
          7        SEND_VAL                                                 <true>
          8        DO_ICALL                                         $16     
          9        ASSIGN                                                   !1, $16
   13    10        ASSIGN                                                   !2, 1
         11      > JMP                                                      ->19
   14    12    >   INIT_METHOD_CALL                                         !0, 'getA'
         13        DO_FCALL                                      0  $19     
         14        ASSIGN                                           ~20     !3, $19
         15        IS_NOT_IDENTICAL                                         ~20, ''
         16      > JMPZ                                                     ~21, ->18
   15    17    >   ECHO                                                     !3
   13    18    >   PRE_INC                                                  !2
         19    >   IS_SMALLER_OR_EQUAL                                      !2, 10000
         20      > JMPNZ                                                    ~23, ->12
   18    21    >   INIT_FCALL                                               'microtime'
         22        SEND_VAL                                                 <true>
         23        DO_ICALL                                         $24     
         24        ASSIGN                                                   !4, $24
   19    25        SUB                                              ~26     !4, !1
         26        ASSIGN                                                   !5, ~26
   20    27        ROPE_INIT                                     3  ~29     'Elapsed+time+was+'
         28        ROPE_ADD                                      1  ~29     ~29, !5
         29        ROPE_END                                      2  ~28     ~29, '+seconds.'
         30        ECHO                                                     ~28
   24    31        INIT_FCALL                                               'microtime'
         32        SEND_VAL                                                 <true>
         33        DO_ICALL                                         $31     
         34        ASSIGN                                                   !6, $31
   25    35        ASSIGN                                                   !2, 1
         36      > JMP                                                      ->45
   26    37    >   INIT_METHOD_CALL                                         !0, 'getA'
         38        DO_FCALL                                      0  $34     
         39        ASSIGN                                           ~35     !3, $34
         40        IS_NOT_IDENTICAL                                         ~35, ''
         41      > JMPZ                                                     ~36, ->43
   27    42    >   ECHO                                                     !3
   29    43    >   UNSET_CV                                                 !3
   25    44        PRE_INC                                                  !2
         45    >   IS_SMALLER_OR_EQUAL                                      !2, 10000
         46      > JMPNZ                                                    ~38, ->37
   31    47    >   INIT_FCALL                                               'microtime'
         48        SEND_VAL                                                 <true>
         49        DO_ICALL                                         $39     
         50        ASSIGN                                                   !7, $39
   32    51        SUB                                              ~41     !7, !6
         52        ASSIGN                                                   !8, ~41
   33    53        ROPE_INIT                                     3  ~44     'Elapsed+time+was+'
         54        ROPE_ADD                                      1  ~44     ~44, !8
         55        ROPE_END                                      2  ~43     ~44, '+seconds.'
         56        ECHO                                                     ~43
   36    57        INIT_FCALL                                               'microtime'
         58        SEND_VAL                                                 <true>
         59        DO_ICALL                                         $46     
         60        ASSIGN                                                   !9, $46
   37    61        ASSIGN                                                   !2, 1
         62      > JMP                                                      ->71
   38    63    >   INIT_METHOD_CALL                                         !0, 'getA'
         64        DO_FCALL                                      0  $49     
         65        IS_NOT_IDENTICAL                                         $49, ''
         66      > JMPZ                                                     ~50, ->70
   39    67    >   INIT_METHOD_CALL                                         !0, 'getA'
         68        DO_FCALL                                      0  $51     
         69        ECHO                                                     $51
   37    70    >   PRE_INC                                                  !2
         71    >   IS_SMALLER_OR_EQUAL                                      !2, 10000
         72      > JMPNZ                                                    ~53, ->63
   42    73    >   INIT_FCALL                                               'microtime'
         74        SEND_VAL                                                 <true>
         75        DO_ICALL                                         $54     
         76        ASSIGN                                                   !10, $54
   43    77        SUB                                              ~56     !10, !9
         78        ASSIGN                                                   !11, ~56
   44    79        ROPE_INIT                                     3  ~59     'Elapsed+time+was+'
         80        ROPE_ADD                                      1  ~59     ~59, !11
         81        ROPE_END                                      2  ~58     ~59, '+seconds.'
         82        ECHO                                                     ~58
         83      > RETURN                                                   1

Class Test:
Function geta:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/X37Wo
function name:  getA
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   FETCH_OBJ_R                                      ~0      'a'
          1      > RETURN                                                   ~0
          2*     > RETURN                                                   null

End of function geta

Function seta:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/X37Wo
function name:  setA
number of ops:  4
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
          1        ASSIGN_OBJ                                               'a'
          2        OP_DATA                                                  !0
          3      > RETURN                                                   null

End of function seta

End of class Test.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149 ms | 1404 KiB | 15 Q