3v4l.org

run code in 300+ PHP versions simultaneously
<?php $isset = true; $array = array(); $notSetArray = array(0=>''); $string = ''; // Test Source function TestEmpty() { $array = null; $i = 0; /* The Test */ $t = microtime(true); while($i < 2000) { !empty($array); ++$i; } echo (microtime(true) - $t); } function TestEmpty2() { $array = null; $i = 0; /* The Test */ $t = microtime(true); while($i < 2000) { (! $array ); ++$i; } echo (microtime(true) - $t); } function TestEmpty3() { $array = null; $i = 0; /* The Test */ $t = microtime(true); while($i < 2000) { ($array != []); ++$i; } echo (microtime(true) - $t); } function TestEmpty4() { $array = null; $i = 0; /* The Test */ $t = microtime(true); while($i < 2000) { ($array != false); ++$i; } echo (microtime(true) - $t); } TestEmpty(); echo "\n\n"; TestEmpty2(); echo "\n\n"; TestEmpty3(); echo "\n\n"; echo TestEmpty4();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/edhDW
function name:  (null)
number of ops:  17
compiled vars:  !0 = $isset, !1 = $array, !2 = $notSetArray, !3 = $string
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <true>
    4     1        ASSIGN                                                   !1, <array>
    5     2        ASSIGN                                                   !2, <array>
    6     3        ASSIGN                                                   !3, ''
   68     4        INIT_FCALL                                               'testempty'
          5        DO_FCALL                                      0          
   69     6        ECHO                                                     '%0A%0A'
   70     7        INIT_FCALL                                               'testempty2'
          8        DO_FCALL                                      0          
   71     9        ECHO                                                     '%0A%0A'
   72    10        INIT_FCALL                                               'testempty3'
         11        DO_FCALL                                      0          
   73    12        ECHO                                                     '%0A%0A'
   74    13        INIT_FCALL                                               'testempty4'
         14        DO_FCALL                                      0  $11     
         15        ECHO                                                     $11
         16      > RETURN                                                   1

Function testempty:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
2 jumps found. (Code = 44) Position 1 = 12, Position 2 = 7
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
2 jumps found. (Code = 44) Position 1 = 12, Position 2 = 7
Branch analysis from position: 12
Branch analysis from position: 7
filename:       /in/edhDW
function name:  TestEmpty
number of ops:  18
compiled vars:  !0 = $array, !1 = $i, !2 = $t
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   ASSIGN                                                   !0, null
   12     1        ASSIGN                                                   !1, 0
   14     2        INIT_FCALL                                               'microtime'
          3        SEND_VAL                                                 <true>
          4        DO_ICALL                                         $5      
          5        ASSIGN                                                   !2, $5
   15     6      > JMP                                                      ->10
   16     7    >   ISSET_ISEMPTY_CV                                 ~7      !0
          8        BOOL_NOT                                         ~8      ~7
   17     9        PRE_INC                                                  !1
   15    10    >   IS_SMALLER                                               !1, 2000
         11      > JMPNZ                                                    ~10, ->7
   20    12    >   INIT_FCALL                                               'microtime'
         13        SEND_VAL                                                 <true>
         14        DO_ICALL                                         $11     
         15        SUB                                              ~12     $11, !2
         16        ECHO                                                     ~12
   21    17      > RETURN                                                   null

End of function testempty

Function testempty2:
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 = 7
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
2 jumps found. (Code = 44) Position 1 = 11, Position 2 = 7
Branch analysis from position: 11
Branch analysis from position: 7
filename:       /in/edhDW
function name:  TestEmpty2
number of ops:  17
compiled vars:  !0 = $array, !1 = $i, !2 = $t
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   ASSIGN                                                   !0, null
   26     1        ASSIGN                                                   !1, 0
   28     2        INIT_FCALL                                               'microtime'
          3        SEND_VAL                                                 <true>
          4        DO_ICALL                                         $5      
          5        ASSIGN                                                   !2, $5
   29     6      > JMP                                                      ->9
   30     7    >   BOOL_NOT                                         ~7      !0
   31     8        PRE_INC                                                  !1
   29     9    >   IS_SMALLER                                               !1, 2000
         10      > JMPNZ                                                    ~9, ->7
   34    11    >   INIT_FCALL                                               'microtime'
         12        SEND_VAL                                                 <true>
         13        DO_ICALL                                         $10     
         14        SUB                                              ~11     $10, !2
         15        ECHO                                                     ~11
   35    16      > RETURN                                                   null

End of function testempty2

Function testempty3:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
2 jumps found. (Code = 44) Position 1 = 12, Position 2 = 7
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
2 jumps found. (Code = 44) Position 1 = 12, Position 2 = 7
Branch analysis from position: 12
Branch analysis from position: 7
filename:       /in/edhDW
function name:  TestEmpty3
number of ops:  18
compiled vars:  !0 = $array, !1 = $i, !2 = $t
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   39     0  E >   ASSIGN                                                   !0, null
   42     1        ASSIGN                                                   !1, 0
   44     2        INIT_FCALL                                               'microtime'
          3        SEND_VAL                                                 <true>
          4        DO_ICALL                                         $5      
          5        ASSIGN                                                   !2, $5
   45     6      > JMP                                                      ->10
   46     7    >   IS_NOT_EQUAL                                     ~7      !0, <array>
          8        FREE                                                     ~7
   47     9        PRE_INC                                                  !1
   45    10    >   IS_SMALLER                                               !1, 2000
         11      > JMPNZ                                                    ~9, ->7
   50    12    >   INIT_FCALL                                               'microtime'
         13        SEND_VAL                                                 <true>
         14        DO_ICALL                                         $10     
         15        SUB                                              ~11     $10, !2
         16        ECHO                                                     ~11
   51    17      > RETURN                                                   null

End of function testempty3

Function testempty4:
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 = 7
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
2 jumps found. (Code = 44) Position 1 = 11, Position 2 = 7
Branch analysis from position: 11
Branch analysis from position: 7
filename:       /in/edhDW
function name:  TestEmpty4
number of ops:  17
compiled vars:  !0 = $array, !1 = $i, !2 = $t
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   54     0  E >   ASSIGN                                                   !0, null
   57     1        ASSIGN                                                   !1, 0
   59     2        INIT_FCALL                                               'microtime'
          3        SEND_VAL                                                 <true>
          4        DO_ICALL                                         $5      
          5        ASSIGN                                                   !2, $5
   60     6      > JMP                                                      ->9
   61     7    >   BOOL                                             ~7      !0
   62     8        PRE_INC                                                  !1
   60     9    >   IS_SMALLER                                               !1, 2000
         10      > JMPNZ                                                    ~9, ->7
   65    11    >   INIT_FCALL                                               'microtime'
         12        SEND_VAL                                                 <true>
         13        DO_ICALL                                         $10     
         14        SUB                                              ~11     $10, !2
         15        ECHO                                                     ~11
   66    16      > RETURN                                                   null

End of function testempty4

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.47 ms | 1407 KiB | 19 Q