3v4l.org

run code in 300+ PHP versions simultaneously
<?php set_time_limit(0); echo "<pre>"; // First Code function m1($a, $b) { $var = null; if ($a == 1) { if ($b == 1) { $var = 'test'; } } return $var; } // Secound Code function m2($a, $b) { $var = null; if ($a == 1 && $b == 1) { $var = 'test'; } return $var; } $result = array( 'm1' => 0, 'm2' => 0 ); // Make sure function get same results assert(m2(0, 0) === m1(0, 0)); assert(m2(1, 1) === m1(1, 1)); // Case 1 with only 1 for($i = 0; $i < 100000; ++ $i) { foreach(array_keys($result) as $key) { $alpha = microtime(true); $key(1, 1); $result[$key] += microtime(true) - $alpha; } } echo '<pre>'; echo "Single Run\n"; print_r($result); echo '</pre>'; // Case 2 with only 1 & 0; $n = 1; for($i = 0; $i < 100000; ++ $i) { foreach(array_keys($result) as $key) { $n = $n ? 0 : 1; $alpha = microtime(true); $key($n, $n); $result[$key] += microtime(true) - $alpha; } } echo '<pre>'; echo "Single Run\n"; print_r($result); echo '</pre>'; ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 57
Branch analysis from position: 57
2 jumps found. (Code = 44) Position 1 = 59, Position 2 = 35
Branch analysis from position: 59
1 jumps found. (Code = 42) Position 1 = 95
Branch analysis from position: 95
2 jumps found. (Code = 44) Position 1 = 97, Position 2 = 68
Branch analysis from position: 97
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 68
2 jumps found. (Code = 77) Position 1 = 72, Position 2 = 93
Branch analysis from position: 72
2 jumps found. (Code = 78) Position 1 = 73, Position 2 = 93
Branch analysis from position: 73
2 jumps found. (Code = 43) Position 1 = 74, Position 2 = 76
Branch analysis from position: 74
1 jumps found. (Code = 42) Position 1 = 77
Branch analysis from position: 77
1 jumps found. (Code = 42) Position 1 = 72
Branch analysis from position: 72
Branch analysis from position: 76
1 jumps found. (Code = 42) Position 1 = 72
Branch analysis from position: 72
Branch analysis from position: 93
2 jumps found. (Code = 44) Position 1 = 97, Position 2 = 68
Branch analysis from position: 97
Branch analysis from position: 68
Branch analysis from position: 93
Branch analysis from position: 35
2 jumps found. (Code = 77) Position 1 = 39, Position 2 = 55
Branch analysis from position: 39
2 jumps found. (Code = 78) Position 1 = 40, Position 2 = 55
Branch analysis from position: 40
1 jumps found. (Code = 42) Position 1 = 39
Branch analysis from position: 39
Branch analysis from position: 55
2 jumps found. (Code = 44) Position 1 = 59, Position 2 = 35
Branch analysis from position: 59
Branch analysis from position: 35
Branch analysis from position: 55
filename:       /in/TFAnT
function name:  (null)
number of ops:  104
compiled vars:  !0 = $result, !1 = $i, !2 = $key, !3 = $alpha, !4 = $n
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   INIT_FCALL                                               'set_time_limit'
          1        SEND_VAL                                                 0
          2        DO_ICALL                                                 
    3     3        ECHO                                                     '%3Cpre%3E'
   25     4        ASSIGN                                                   !0, <array>
   31     5        ASSERT_CHECK                                             
          6        INIT_FCALL                                               'assert'
          7        INIT_FCALL                                               'm2'
          8        SEND_VAL                                                 0
          9        SEND_VAL                                                 0
         10        DO_FCALL                                      0  $7      
         11        INIT_FCALL                                               'm1'
         12        SEND_VAL                                                 0
         13        SEND_VAL                                                 0
         14        DO_FCALL                                      0  $8      
         15        IS_IDENTICAL                                     ~9      $7, $8
         16        SEND_VAL                                                 ~9
         17        SEND_VAL                                                 'assert%28m2%280%2C+0%29+%3D%3D%3D+m1%280%2C+0%29%29'
         18        DO_ICALL                                                 
   32    19        ASSERT_CHECK                                             
         20        INIT_FCALL                                               'assert'
         21        INIT_FCALL                                               'm2'
         22        SEND_VAL                                                 1
         23        SEND_VAL                                                 1
         24        DO_FCALL                                      0  $11     
         25        INIT_FCALL                                               'm1'
         26        SEND_VAL                                                 1
         27        SEND_VAL                                                 1
         28        DO_FCALL                                      0  $12     
         29        IS_IDENTICAL                                     ~13     $11, $12
         30        SEND_VAL                                                 ~13
         31        SEND_VAL                                                 'assert%28m2%281%2C+1%29+%3D%3D%3D+m1%281%2C+1%29%29'
         32        DO_ICALL                                                 
   35    33        ASSIGN                                                   !1, 0
         34      > JMP                                                      ->57
   36    35    >   INIT_FCALL                                               'array_keys'
         36        SEND_VAR                                                 !0
         37        DO_ICALL                                         $16     
         38      > FE_RESET_R                                       $17     $16, ->55
         39    > > FE_FETCH_R                                               $17, !2, ->55
   37    40    >   INIT_FCALL                                               'microtime'
         41        SEND_VAL                                                 <true>
         42        DO_ICALL                                         $18     
         43        ASSIGN                                                   !3, $18
   38    44        INIT_DYNAMIC_CALL                                        !2
         45        SEND_VAL_EX                                              1
         46        SEND_VAL_EX                                              1
         47        DO_FCALL                                      0          
   39    48        INIT_FCALL                                               'microtime'
         49        SEND_VAL                                                 <true>
         50        DO_ICALL                                         $22     
         51        SUB                                              ~23     $22, !3
         52        ASSIGN_DIM_OP                +=               1          !0, !2
         53        OP_DATA                                                  ~23
   36    54      > JMP                                                      ->39
         55    >   FE_FREE                                                  $17
   35    56        PRE_INC                                                  !1
         57    >   IS_SMALLER                                               !1, 100000
         58      > JMPNZ                                                    ~25, ->35
   43    59    >   ECHO                                                     '%3Cpre%3E'
   44    60        ECHO                                                     'Single+Run%0A'
   45    61        INIT_FCALL                                               'print_r'
         62        SEND_VAR                                                 !0
         63        DO_ICALL                                                 
   46    64        ECHO                                                     '%3C%2Fpre%3E'
   50    65        ASSIGN                                                   !4, 1
   51    66        ASSIGN                                                   !1, 0
         67      > JMP                                                      ->95
   52    68    >   INIT_FCALL                                               'array_keys'
         69        SEND_VAR                                                 !0
         70        DO_ICALL                                         $29     
         71      > FE_RESET_R                                       $30     $29, ->93
         72    > > FE_FETCH_R                                               $30, !2, ->93
   53    73    > > JMPZ                                                     !4, ->76
         74    >   QM_ASSIGN                                        ~31     0
         75      > JMP                                                      ->77
         76    >   QM_ASSIGN                                        ~31     1
         77    >   ASSIGN                                                   !4, ~31
   54    78        INIT_FCALL                                               'microtime'
         79        SEND_VAL                                                 <true>
         80        DO_ICALL                                         $33     
         81        ASSIGN                                                   !3, $33
   55    82        INIT_DYNAMIC_CALL                                        !2
         83        SEND_VAR_EX                                              !4
         84        SEND_VAR_EX                                              !4
         85        DO_FCALL                                      0          
   56    86        INIT_FCALL                                               'microtime'
         87        SEND_VAL                                                 <true>
         88        DO_ICALL                                         $37     
         89        SUB                                              ~38     $37, !3
         90        ASSIGN_DIM_OP                +=               1          !0, !2
         91        OP_DATA                                                  ~38
   52    92      > JMP                                                      ->72
         93    >   FE_FREE                                                  $30
   51    94        PRE_INC                                                  !1
         95    >   IS_SMALLER                                               !1, 100000
         96      > JMPNZ                                                    ~40, ->68
   60    97    >   ECHO                                                     '%3Cpre%3E'
   61    98        ECHO                                                     'Single+Run%0A'
   62    99        INIT_FCALL                                               'print_r'
        100        SEND_VAR                                                 !0
        101        DO_ICALL                                                 
   63   102        ECHO                                                     '%3C%2Fpre%3E'
   65   103      > RETURN                                                   1

Function m1:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 8
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 8
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
Branch analysis from position: 8
filename:       /in/TFAnT
function name:  m1
number of ops:  10
compiled vars:  !0 = $a, !1 = $b, !2 = $var
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    7     2        ASSIGN                                                   !2, null
    8     3        IS_EQUAL                                                 !0, 1
          4      > JMPZ                                                     ~4, ->8
    9     5    >   IS_EQUAL                                                 !1, 1
          6      > JMPZ                                                     ~5, ->8
   10     7    >   ASSIGN                                                   !2, 'test'
   13     8    > > RETURN                                                   !2
   14     9*     > RETURN                                                   null

End of function m1

Function m2:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 5, Position 2 = 7
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 9
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
Branch analysis from position: 7
filename:       /in/TFAnT
function name:  m2
number of ops:  11
compiled vars:  !0 = $a, !1 = $b, !2 = $var
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   18     2        ASSIGN                                                   !2, null
   19     3        IS_EQUAL                                         ~4      !0, 1
          4      > JMPZ_EX                                          ~4      ~4, ->7
          5    >   IS_EQUAL                                         ~5      !1, 1
          6        BOOL                                             ~4      ~5
          7    > > JMPZ                                                     ~4, ->9
   20     8    >   ASSIGN                                                   !2, 'test'
   22     9    > > RETURN                                                   !2
   23    10*     > RETURN                                                   null

End of function m2

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.01 ms | 1411 KiB | 27 Q