3v4l.org

run code in 300+ PHP versions simultaneously
<?php $isset = true; $array = array(); $notSetArray = array(0=>''); $string = ''; // Test Source function TestEmpty() { $array = array(); unset($array); /* The Test */ $t = microtime(true); while($i < 2000) { empty($array); ++$i; } echo (microtime(true) - $t); } function TestEmpty2() { $array = array(); unset($array); /* The Test */ $t = microtime(true); while($i < 2000) { ($array == []); ++$i; } echo (microtime(true) - $t); } function TestEmpty3() { $array = array(); unset($array); /* The Test */ $t = microtime(true); while($i < 2000) { ($array === []); ++$i; } echo (microtime(true) - $t); } TestEmpty(); echo '<hr>-----'; TestEmpty2(); echo '<hr>-----'; TestEmpty3();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/aEZ6m
function name:  (null)
number of ops:  13
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, ''
   52     4        INIT_FCALL                                               'testempty'
          5        DO_FCALL                                      0          
   53     6        ECHO                                                     '%3Chr%3E-----'
   54     7        INIT_FCALL                                               'testempty2'
          8        DO_FCALL                                      0          
   55     9        ECHO                                                     '%3Chr%3E-----'
   56    10        INIT_FCALL                                               'testempty3'
         11        DO_FCALL                                      0          
         12      > 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/aEZ6m
function name:  TestEmpty
number of ops:  18
compiled vars:  !0 = $array, !1 = $t, !2 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   ASSIGN                                                   !0, <array>
   11     1        UNSET_CV                                                 !0
   14     2        INIT_FCALL                                               'microtime'
          3        SEND_VAL                                                 <true>
          4        DO_ICALL                                         $4      
          5        ASSIGN                                                   !1, $4
   15     6      > JMP                                                      ->10
   16     7    >   ISSET_ISEMPTY_CV                                 ~6      !0
          8        FREE                                                     ~6
   17     9        PRE_INC                                                  !2
   15    10    >   IS_SMALLER                                               !2, 2000
         11      > JMPNZ                                                    ~8, ->7
   20    12    >   INIT_FCALL                                               'microtime'
         13        SEND_VAL                                                 <true>
         14        DO_ICALL                                         $9      
         15        SUB                                              ~10     $9, !1
         16        ECHO                                                     ~10
   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 = 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/aEZ6m
function name:  TestEmpty2
number of ops:  18
compiled vars:  !0 = $array, !1 = $t, !2 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   ASSIGN                                                   !0, <array>
   25     1        UNSET_CV                                                 !0
   28     2        INIT_FCALL                                               'microtime'
          3        SEND_VAL                                                 <true>
          4        DO_ICALL                                         $4      
          5        ASSIGN                                                   !1, $4
   29     6      > JMP                                                      ->10
   30     7    >   IS_EQUAL                                         ~6      !0, <array>
          8        FREE                                                     ~6
   31     9        PRE_INC                                                  !2
   29    10    >   IS_SMALLER                                               !2, 2000
         11      > JMPNZ                                                    ~8, ->7
   34    12    >   INIT_FCALL                                               'microtime'
         13        SEND_VAL                                                 <true>
         14        DO_ICALL                                         $9      
         15        SUB                                              ~10     $9, !1
         16        ECHO                                                     ~10
   35    17      > 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/aEZ6m
function name:  TestEmpty3
number of ops:  18
compiled vars:  !0 = $array, !1 = $t, !2 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   39     0  E >   ASSIGN                                                   !0, <array>
   40     1        UNSET_CV                                                 !0
   43     2        INIT_FCALL                                               'microtime'
          3        SEND_VAL                                                 <true>
          4        DO_ICALL                                         $4      
          5        ASSIGN                                                   !1, $4
   44     6      > JMP                                                      ->10
   45     7    >   IS_IDENTICAL                                     ~6      !0, <array>
          8        FREE                                                     ~6
   46     9        PRE_INC                                                  !2
   44    10    >   IS_SMALLER                                               !2, 2000
         11      > JMPNZ                                                    ~8, ->7
   49    12    >   INIT_FCALL                                               'microtime'
         13        SEND_VAL                                                 <true>
         14        DO_ICALL                                         $9      
         15        SUB                                              ~10     $9, !1
         16        ECHO                                                     ~10
   50    17      > RETURN                                                   null

End of function testempty3

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.05 ms | 1407 KiB | 18 Q