3v4l.org

run code in 500+ PHP versions simultaneously
<?php $numbers = range(0,100000); $start = microtime(true); $justThousand = []; foreach($numbers as $num){ if($num > 1000 && $num < 6000){ $justThousand[] = $num; } } $end = microtime(true); echo "foreach: ".$end - $start."\n"; $start = microtime(true); function IsThousand($num){ return $num > 1000 && $num < 6000; } $justThousand = array_filter($numbers,'IsThousand'); $end = microtime(true); echo "array_filter: ".$end - $start;
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 11, Position 2 = 20
Branch analysis from position: 11
2 jumps found. (Code = 78) Position 1 = 12, Position 2 = 20
Branch analysis from position: 12
2 jumps found. (Code = 46) Position 1 = 14, Position 2 = 16
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 19
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 19
Branch analysis from position: 16
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
filename:       /in/VYYUqH
function name:  (null)
number of ops:  46
compiled vars:  !0 = $numbers, !1 = $start, !2 = $justThousand, !3 = $num, !4 = $end
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                                   'range'
          1        SEND_VAL                                                     0
          2        SEND_VAL                                                     100000
          3        DO_ICALL                                             $5      
          4        ASSIGN                                                       !0, $5
    5     5        INIT_FCALL                                                   'microtime'
          6        SEND_VAL                                                     <true>
          7        DO_ICALL                                             $7      
          8        ASSIGN                                                       !1, $7
    6     9        ASSIGN                                                       !2, <array>
    7    10      > FE_RESET_R                                           $10     !0, ->20
         11    > > FE_FETCH_R                                                   $10, !3, ->20
    8    12    >   IS_SMALLER                                           ~11     1000, !3
         13      > JMPZ_EX                                              ~11     ~11, ->16
         14    >   IS_SMALLER                                           ~12     !3, 6000
         15        BOOL                                                 ~11     ~12
         16    > > JMPZ                                                         ~11, ->19
    9    17    >   ASSIGN_DIM                                                   !2
         18        OP_DATA                                                      !3
    7    19    > > JMP                                                          ->11
         20    >   FE_FREE                                                      $10
   13    21        INIT_FCALL                                                   'microtime'
         22        SEND_VAL                                                     <true>
         23        DO_ICALL                                             $14     
         24        ASSIGN                                                       !4, $14
   15    25        SUB                                                  ~16     !4, !1
         26        CONCAT                                               ~17     'foreach%3A++++++', ~16
         27        CONCAT                                               ~18     ~17, '%0A'
         28        ECHO                                                         ~18
   17    29        INIT_FCALL                                                   'microtime'
         30        SEND_VAL                                                     <true>
         31        DO_ICALL                                             $19     
         32        ASSIGN                                                       !1, $19
   23    33        INIT_FCALL                                                   'array_filter'
         34        SEND_VAR                                                     !0
         35        SEND_VAL                                                     'IsThousand'
         36        DO_ICALL                                             $21     
         37        ASSIGN                                                       !2, $21
   24    38        INIT_FCALL                                                   'microtime'
         39        SEND_VAL                                                     <true>
         40        DO_ICALL                                             $23     
         41        ASSIGN                                                       !4, $23
   26    42        SUB                                                  ~25     !4, !1
         43        CONCAT                                               ~26     'array_filter%3A+', ~25
         44        ECHO                                                         ~26
   27    45      > RETURN                                                       1

Function isthousand:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 3, Position 2 = 5
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
filename:       /in/VYYUqH
function name:  IsThousand
number of ops:  7
compiled vars:  !0 = $num
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   19     0  E >   RECV                                                 !0      
   20     1        IS_SMALLER                                           ~1      1000, !0
          2      > JMPZ_EX                                              ~1      ~1, ->5
          3    >   IS_SMALLER                                           ~2      !0, 6000
          4        BOOL                                                 ~1      ~2
          5    > > RETURN                                                       ~1
   21     6*     > RETURN                                                       null

End of function isthousand

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
157.33 ms | 1381 KiB | 16 Q