3v4l.org

run code in 300+ PHP versions simultaneously
<?php function isProgression($array){ return ($array == range(0, $array[sizeof($array)-1])); } function isProgression2($array){ $count = count($array); for ($i = 0; $i < $count; ++$i) { if($array[$i] != $i){ return true; } } return false; } for ($x = 0; $x < 10000; $x++) { // Pick one isProgression(array(0,1,2,3,4,5)); //isProgression2(array(0,1,2,3,4,5)); }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
2 jumps found. (Code = 44) Position 1 = 8, Position 2 = 2
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 2
2 jumps found. (Code = 44) Position 1 = 8, Position 2 = 2
Branch analysis from position: 8
Branch analysis from position: 2
filename:       /in/098QX
function name:  (null)
number of ops:  9
compiled vars:  !0 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   ASSIGN                                                   !0, 0
          1      > JMP                                                      ->6
   18     2    >   INIT_FCALL                                               'isprogression'
          3        SEND_VAL                                                 <array>
          4        DO_FCALL                                      0          
   16     5        PRE_INC                                                  !0
          6    >   IS_SMALLER                                               !0, 10000
          7      > JMPNZ                                                    ~4, ->2
   20     8    > > RETURN                                                   1

Function isprogression:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/098QX
function name:  isProgression
number of ops:  11
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    3     1        INIT_FCALL                                               'range'
          2        SEND_VAL                                                 0
          3        COUNT                                            ~1      !0
          4        SUB                                              ~2      ~1, 1
          5        FETCH_DIM_R                                      ~3      !0, ~2
          6        SEND_VAL                                                 ~3
          7        DO_ICALL                                         $4      
          8        IS_EQUAL                                         ~5      !0, $4
          9      > RETURN                                                   ~5
    4    10*     > RETURN                                                   null

End of function isprogression

Function isprogression2:
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 = 5
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
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
2 jumps found. (Code = 44) Position 1 = 12, Position 2 = 5
Branch analysis from position: 12
Branch analysis from position: 5
filename:       /in/098QX
function name:  isProgression2
number of ops:  14
compiled vars:  !0 = $array, !1 = $count, !2 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
    7     1        COUNT                                            ~3      !0
          2        ASSIGN                                                   !1, ~3
    8     3        ASSIGN                                                   !2, 0
          4      > JMP                                                      ->10
    9     5    >   FETCH_DIM_R                                      ~6      !0, !2
          6        IS_NOT_EQUAL                                             !2, ~6
          7      > JMPZ                                                     ~7, ->9
   10     8    > > RETURN                                                   <true>
    8     9    >   PRE_INC                                                  !2
         10    >   IS_SMALLER                                               !2, !1
         11      > JMPNZ                                                    ~9, ->5
   13    12    > > RETURN                                                   <false>
   14    13*     > RETURN                                                   null

End of function isprogression2

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.37 ms | 1403 KiB | 16 Q