3v4l.org

run code in 500+ PHP versions simultaneously
<?php $array = array('test1', 'test2', 'test3', 'test4'); $var = 'test'; $iterations = 1000000; $start = microtime(true); for($i = 0; $i < $iterations; ++$i) { if ($var != 'test1' && $var != 'test2' && $var != 'test3' && $var != 'test4') {} } $end = microtime(true); print "multiple comparisons: \n". ($end - $start)."\n"; $start2 = microtime(true); for($i = 0; $i < $iterations; ++$i) { if (!in_array($var, $array) ) {} } $end2 = microtime(true); print "in_array: \n".($end2 - $start2)."\n"; $start = microtime(true); $array_flip = array_flip($array); for($i = 0; $i < $iterations; ++$i) { if (!isset($array_flip[$var])) {} } $end = microtime(true); print "array_flip() outside loop measured + isset(): \n".($end - $start)."\n"; $array_flip = array_flip($array); $start = microtime(true); for($i = 0; $i < $iterations; ++$i) { if (!isset($array_flip[$var])) {} } $end = microtime(true); print "array_flip() outside loop not measured + isset(): \n".($end - $start)."\n"; $start = microtime(true); for($i = 0; $i < $iterations; ++$i) { foreach ($array as $entry) { if ($entry == $var) {} } } $end = microtime(true); print "foreach and compoarison: \n".($end - $start)."\n";

Abusive script

This script was stopped while abusing our resources

Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
2 jumps found. (Code = 44) Position 1 = 23, Position 2 = 9
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 41
Branch analysis from position: 41
2 jumps found. (Code = 44) Position 1 = 43, Position 2 = 37
Branch analysis from position: 43
1 jumps found. (Code = 42) Position 1 = 65
Branch analysis from position: 65
2 jumps found. (Code = 44) Position 1 = 67, Position 2 = 61
Branch analysis from position: 67
1 jumps found. (Code = 42) Position 1 = 89
Branch analysis from position: 89
2 jumps found. (Code = 44) Position 1 = 91, Position 2 = 85
Branch analysis from position: 91
1 jumps found. (Code = 42) Position 1 = 112
Branch analysis from position: 112
2 jumps found. (Code = 44) Position 1 = 114, Position 2 = 105
Branch analysis from position: 114
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 105
2 jumps found. (Code = 77) Position 1 = 106, Position 2 = 110
Branch analysis from position: 106
2 jumps found. (Code = 78) Position 1 = 107, Position 2 = 110
Branch analysis from position: 107
2 jumps found. (Code = 43) Position 1 = 109, Position 2 = 109
Branch analysis from position: 109
1 jumps found. (Code = 42) Position 1 = 106
Branch analysis from position: 106
Branch analysis from position: 109
Branch analysis from position: 110
2 jumps found. (Code = 44) Position 1 = 114, Position 2 = 105
Branch analysis from position: 114
Branch analysis from position: 105
Branch analysis from position: 110
Branch analysis from position: 85
2 jumps found. (Code = 43) Position 1 = 88, Position 2 = 88
Branch analysis from position: 88
2 jumps found. (Code = 44) Position 1 = 91, Position 2 = 85
Branch analysis from position: 91
Branch analysis from position: 85
Branch analysis from position: 88
Branch analysis from position: 61
2 jumps found. (Code = 43) Position 1 = 64, Position 2 = 64
Branch analysis from position: 64
2 jumps found. (Code = 44) Position 1 = 67, Position 2 = 61
Branch analysis from position: 67
Branch analysis from position: 61
Branch analysis from position: 64
Branch analysis from position: 37
2 jumps found. (Code = 43) Position 1 = 40, Position 2 = 40
Branch analysis from position: 40
2 jumps found. (Code = 44) Position 1 = 43, Position 2 = 37
Branch analysis from position: 43
Branch analysis from position: 37
Branch analysis from position: 40
Branch analysis from position: 9
2 jumps found. (Code = 46) Position 1 = 11, Position 2 = 13
Branch analysis from position: 11
2 jumps found. (Code = 46) Position 1 = 14, Position 2 = 16
Branch analysis from position: 14
2 jumps found. (Code = 46) Position 1 = 17, Position 2 = 19
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 20
Branch analysis from position: 20
2 jumps found. (Code = 44) Position 1 = 23, Position 2 = 9
Branch analysis from position: 23
Branch analysis from position: 9
Branch analysis from position: 20
Branch analysis from position: 19
Branch analysis from position: 16
Branch analysis from position: 13
filename:       /in/OA2S7
function name:  (null)
number of ops:  123
compiled vars:  !0 = $array, !1 = $var, !2 = $iterations, !3 = $start, !4 = $i, !5 = $end, !6 = $start2, !7 = $end2, !8 = $array_flip, !9 = $entry
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
    4     1        ASSIGN                                                       !1, 'test'
    5     2        ASSIGN                                                       !2, 1000000
    7     3        INIT_FCALL                                                   'microtime'
          4        SEND_VAL                                                     <true>
          5        DO_ICALL                                             $13     
          6        ASSIGN                                                       !3, $13
    8     7        ASSIGN                                                       !4, 0
          8      > JMP                                                          ->21
    9     9    >   IS_NOT_EQUAL                                         ~16     !1, 'test1'
         10      > JMPZ_EX                                              ~16     ~16, ->13
         11    >   IS_NOT_EQUAL                                         ~17     !1, 'test2'
         12        BOOL                                                 ~16     ~17
         13    > > JMPZ_EX                                              ~16     ~16, ->16
         14    >   IS_NOT_EQUAL                                         ~18     !1, 'test3'
         15        BOOL                                                 ~16     ~18
         16    > > JMPZ_EX                                              ~16     ~16, ->19
         17    >   IS_NOT_EQUAL                                         ~19     !1, 'test4'
         18        BOOL                                                 ~16     ~19
         19    > > JMPZ                                                         ~16, ->20
    8    20    >   PRE_INC                                                      !4
         21    >   IS_SMALLER                                                   !4, !2
         22      > JMPNZ                                                        ~21, ->9
   11    23    >   INIT_FCALL                                                   'microtime'
         24        SEND_VAL                                                     <true>
         25        DO_ICALL                                             $22     
         26        ASSIGN                                                       !5, $22
   13    27        SUB                                                  ~24     !5, !3
         28        CONCAT                                               ~25     'multiple+comparisons%3A+%0A', ~24
         29        CONCAT                                               ~26     ~25, '%0A'
         30        ECHO                                                         ~26
   15    31        INIT_FCALL                                                   'microtime'
         32        SEND_VAL                                                     <true>
         33        DO_ICALL                                             $27     
         34        ASSIGN                                                       !6, $27
   16    35        ASSIGN                                                       !4, 0
         36      > JMP                                                          ->41
   17    37    >   FRAMELESS_ICALL_2                in_array            ~30     !1, !0
         38        BOOL_NOT                                             ~31     ~30
         39      > JMPZ                                                         ~31, ->40
   16    40    >   PRE_INC                                                      !4
         41    >   IS_SMALLER                                                   !4, !2
         42      > JMPNZ                                                        ~33, ->37
   19    43    >   INIT_FCALL                                                   'microtime'
         44        SEND_VAL                                                     <true>
         45        DO_ICALL                                             $34     
         46        ASSIGN                                                       !7, $34
   21    47        SUB                                                  ~36     !7, !6
         48        CONCAT                                               ~37     'in_array%3A+%0A', ~36
         49        CONCAT                                               ~38     ~37, '%0A'
         50        ECHO                                                         ~38
   23    51        INIT_FCALL                                                   'microtime'
         52        SEND_VAL                                                     <true>
         53        DO_ICALL                                             $39     
         54        ASSIGN                                                       !3, $39
   24    55        INIT_FCALL                                                   'array_flip'
         56        SEND_VAR                                                     !0
         57        DO_ICALL                                             $41     
         58        ASSIGN                                                       !8, $41
   26    59        ASSIGN                                                       !4, 0
         60      > JMP                                                          ->65
   27    61    >   ISSET_ISEMPTY_DIM_OBJ                             0  ~44     !8, !1
         62        BOOL_NOT                                             ~45     ~44
         63      > JMPZ                                                         ~45, ->64
   26    64    >   PRE_INC                                                      !4
         65    >   IS_SMALLER                                                   !4, !2
         66      > JMPNZ                                                        ~47, ->61
   29    67    >   INIT_FCALL                                                   'microtime'
         68        SEND_VAL                                                     <true>
         69        DO_ICALL                                             $48     
         70        ASSIGN                                                       !5, $48
   30    71        SUB                                                  ~50     !5, !3
         72        CONCAT                                               ~51     'array_flip%28%29+outside+loop+measured+%2B+isset%28%29%3A+%0A', ~50
         73        CONCAT                                               ~52     ~51, '%0A'
         74        ECHO                                                         ~52
   32    75        INIT_FCALL                                                   'array_flip'
         76        SEND_VAR                                                     !0
         77        DO_ICALL                                             $53     
         78        ASSIGN                                                       !8, $53
   33    79        INIT_FCALL                                                   'microtime'
         80        SEND_VAL                                                     <true>
         81        DO_ICALL                                             $55     
         82        ASSIGN                                                       !3, $55
   35    83        ASSIGN                                                       !4, 0
         84      > JMP                                                          ->89
   36    85    >   ISSET_ISEMPTY_DIM_OBJ                             0  ~58     !8, !1
         86        BOOL_NOT                                             ~59     ~58
         87      > JMPZ                                                         ~59, ->88
   35    88    >   PRE_INC                                                      !4
         89    >   IS_SMALLER                                                   !4, !2
         90      > JMPNZ                                                        ~61, ->85
   38    91    >   INIT_FCALL                                                   'microtime'
         92        SEND_VAL                                                     <true>
         93        DO_ICALL                                             $62     
         94        ASSIGN                                                       !5, $62
   39    95        SUB                                                  ~64     !5, !3
         96        CONCAT                                               ~65     'array_flip%28%29+outside+loop+not+measured+%2B+isset%28%29%3A+%0A', ~64
         97        CONCAT                                               ~66     ~65, '%0A'
         98        ECHO                                                         ~66
   41    99        INIT_FCALL                                                   'microtime'
        100        SEND_VAL                                                     <true>
        101        DO_ICALL                                             $67     
        102        ASSIGN                                                       !3, $67
   43   103        ASSIGN                                                       !4, 0
        104      > JMP                                                          ->112
   44   105    > > FE_RESET_R                                           $70     !0, ->110
        106    > > FE_FETCH_R                                                   $70, !9, ->110
   45   107    >   IS_EQUAL                                                     !9, !1
        108      > JMPZ                                                         ~71, ->109
   44   109    > > JMP                                                          ->106
        110    >   FE_FREE                                                      $70
   43   111        PRE_INC                                                      !4
        112    >   IS_SMALLER                                                   !4, !2
        113      > JMPNZ                                                        ~73, ->105
   48   114    >   INIT_FCALL                                                   'microtime'
        115        SEND_VAL                                                     <true>
        116        DO_ICALL                                             $74     
        117        ASSIGN                                                       !5, $74
   49   118        SUB                                                  ~76     !5, !3
        119        CONCAT                                               ~77     'foreach+and+compoarison%3A+%0A', ~76
        120        CONCAT                                               ~78     ~77, '%0A'
        121        ECHO                                                         ~78
        122      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
153.75 ms | 2462 KiB | 10 Q