3v4l.org

run code in 300+ PHP versions simultaneously
<?php ini_set( 'MAX_EXEC_TIME', 120 ); $num_tests = 10; $startFirst = $startSecond = $endFirst = $endSecond = $startFirstMemory = $endFirstMemory = $startSecondMemory = $endSecondMemory = $someVal = 0; $times = array( '$i++' => array( 'time' => 0, 'memory' => 0 ), '++$i' => array( 'total' => 0, 'memory' => 0 ) ); for( $j = 0; $j < $num_tests; ++$j ) { for( $i = 0, $startFirstMemory = memory_get_usage( ), $startFirst = microtime( true ); $i < 10000000; $i++ ){ $someval = 2; } $endFirstMemory = memory_get_usage( ); $endFirst = microtime( true ); for( $i = 0, $startSecondMemory = memory_get_usage( ), $startSecond = microtime( true ); $i < 10000000; ++$i ){ $someval = 2; } $endSecondMemory = memory_get_usage( ); $endSecond = microtime( true ); $times[ '$i++' ][ $j ] = array( 'startTime' => $startFirst, 'endTime' => $endFirst, 'startMemory' => $startFirstMemory, 'endMemory' => $endFirstMemory ); $times[ '++$i' ][ $j ] = array( 'startTime' => $startSecond, 'endTime' => $endSecond, 'startMemory' => $startSecondMemory, 'endMemory' => $endSecondMemory ); } for( $i = 0; $i < $num_tests; ++$i ) { $times[ '$i++' ][ 'time' ] += ( $times[ '$i++' ][ $i ][ 'endTime' ] - $times[ '$i++' ][ $i ][ 'startTime' ] ); $times[ '++$i' ][ 'time' ] += ( $times[ '++$i' ][ $i ][ 'endTime' ] - $times[ '++$i' ][ $i ][ 'startTime' ] ); $times[ '$i++' ][ 'memory' ] += ( $times[ '$i++' ][ $i ][ 'endMemory' ] - $times[ '$i++' ][ $i ][ 'startMemory' ] ); $times[ '++$i' ][ 'memory' ] += ( $times[ '++$i' ][ $i ][ 'endMemory' ] - $times[ '++$i' ][ $i ][ 'startMemory' ] ); } echo 'There were ' . $num_tests . ' tests conducted, here\'s the totals<br /><br /> $i++ took ' . $times[ '$i++' ][ 'time' ] . ' seconds and ' . $times[ '$i++' ][ 'memory' ] . ' bytes<br /> ++$i took ' . $times[ '++$i' ][ 'time' ] . ' seconds and ' . $times[ '++$i' ][ 'memory' ] . ' bytes';
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 72
Branch analysis from position: 72
2 jumps found. (Code = 44) Position 1 = 74, Position 2 = 17
Branch analysis from position: 74
1 jumps found. (Code = 42) Position 1 = 117
Branch analysis from position: 117
2 jumps found. (Code = 44) Position 1 = 119, Position 2 = 76
Branch analysis from position: 119
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 76
2 jumps found. (Code = 44) Position 1 = 119, Position 2 = 76
Branch analysis from position: 119
Branch analysis from position: 76
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 28
Branch analysis from position: 28
2 jumps found. (Code = 44) Position 1 = 30, Position 2 = 26
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 48
Branch analysis from position: 48
2 jumps found. (Code = 44) Position 1 = 50, Position 2 = 46
Branch analysis from position: 50
2 jumps found. (Code = 44) Position 1 = 74, Position 2 = 17
Branch analysis from position: 74
Branch analysis from position: 17
Branch analysis from position: 46
2 jumps found. (Code = 44) Position 1 = 50, Position 2 = 46
Branch analysis from position: 50
Branch analysis from position: 46
Branch analysis from position: 26
2 jumps found. (Code = 44) Position 1 = 30, Position 2 = 26
Branch analysis from position: 30
Branch analysis from position: 26
filename:       /in/5aNS1
function name:  (null)
number of ops:  139
compiled vars:  !0 = $num_tests, !1 = $startFirst, !2 = $startSecond, !3 = $endFirst, !4 = $endSecond, !5 = $startFirstMemory, !6 = $endFirstMemory, !7 = $startSecondMemory, !8 = $endSecondMemory, !9 = $someVal, !10 = $times, !11 = $j, !12 = $i, !13 = $someval
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'ini_set'
          1        SEND_VAL                                                 'MAX_EXEC_TIME'
          2        SEND_VAL                                                 120
          3        DO_ICALL                                                 
    5     4        ASSIGN                                                   !0, 10
    6     5        ASSIGN                                           ~16     !9, 0
          6        ASSIGN                                           ~17     !8, ~16
          7        ASSIGN                                           ~18     !7, ~17
          8        ASSIGN                                           ~19     !6, ~18
          9        ASSIGN                                           ~20     !5, ~19
         10        ASSIGN                                           ~21     !4, ~20
         11        ASSIGN                                           ~22     !3, ~21
         12        ASSIGN                                           ~23     !2, ~22
         13        ASSIGN                                                   !1, ~23
    7    14        ASSIGN                                                   !10, <array>
    9    15        ASSIGN                                                   !11, 0
         16      > JMP                                                      ->72
   11    17    >   ASSIGN                                                   !12, 0
         18        INIT_FCALL                                               'memory_get_usage'
         19        DO_ICALL                                         $28     
         20        ASSIGN                                                   !5, $28
         21        INIT_FCALL                                               'microtime'
         22        SEND_VAL                                                 <true>
         23        DO_ICALL                                         $30     
         24        ASSIGN                                                   !1, $30
         25      > JMP                                                      ->28
         26    >   ASSIGN                                                   !13, 2
         27        PRE_INC                                                  !12
         28    >   IS_SMALLER                                               !12, 10000000
         29      > JMPNZ                                                    ~34, ->26
   12    30    >   INIT_FCALL                                               'memory_get_usage'
         31        DO_ICALL                                         $35     
         32        ASSIGN                                                   !6, $35
   13    33        INIT_FCALL                                               'microtime'
         34        SEND_VAL                                                 <true>
         35        DO_ICALL                                         $37     
         36        ASSIGN                                                   !3, $37
   15    37        ASSIGN                                                   !12, 0
         38        INIT_FCALL                                               'memory_get_usage'
         39        DO_ICALL                                         $40     
         40        ASSIGN                                                   !7, $40
         41        INIT_FCALL                                               'microtime'
         42        SEND_VAL                                                 <true>
         43        DO_ICALL                                         $42     
         44        ASSIGN                                                   !2, $42
         45      > JMP                                                      ->48
         46    >   ASSIGN                                                   !13, 2
         47        PRE_INC                                                  !12
         48    >   IS_SMALLER                                               !12, 10000000
         49      > JMPNZ                                                    ~46, ->46
   16    50    >   INIT_FCALL                                               'memory_get_usage'
         51        DO_ICALL                                         $47     
         52        ASSIGN                                                   !8, $47
   17    53        INIT_FCALL                                               'microtime'
         54        SEND_VAL                                                 <true>
         55        DO_ICALL                                         $49     
         56        ASSIGN                                                   !4, $49
   19    57        INIT_ARRAY                                       ~53     !1, 'startTime'
         58        ADD_ARRAY_ELEMENT                                ~53     !3, 'endTime'
         59        ADD_ARRAY_ELEMENT                                ~53     !5, 'startMemory'
         60        ADD_ARRAY_ELEMENT                                ~53     !6, 'endMemory'
         61        FETCH_DIM_W                                      $51     !10, '%24i%2B%2B'
         62        ASSIGN_DIM                                               $51, !11
         63        OP_DATA                                                  ~53
   20    64        INIT_ARRAY                                       ~56     !2, 'startTime'
         65        ADD_ARRAY_ELEMENT                                ~56     !4, 'endTime'
         66        ADD_ARRAY_ELEMENT                                ~56     !7, 'startMemory'
         67        ADD_ARRAY_ELEMENT                                ~56     !8, 'endMemory'
         68        FETCH_DIM_W                                      $54     !10, '%2B%2B%24i'
         69        ASSIGN_DIM                                               $54, !11
         70        OP_DATA                                                  ~56
    9    71        PRE_INC                                                  !11
         72    >   IS_SMALLER                                               !11, !0
         73      > JMPNZ                                                    ~58, ->17
   23    74    >   ASSIGN                                                   !12, 0
         75      > JMP                                                      ->117
   25    76    >   FETCH_DIM_R                                      ~62     !10, '%24i%2B%2B'
         77        FETCH_DIM_R                                      ~63     ~62, !12
         78        FETCH_DIM_R                                      ~64     ~63, 'endTime'
         79        FETCH_DIM_R                                      ~65     !10, '%24i%2B%2B'
         80        FETCH_DIM_R                                      ~66     ~65, !12
         81        FETCH_DIM_R                                      ~67     ~66, 'startTime'
         82        SUB                                              ~68     ~64, ~67
         83        FETCH_DIM_RW                                     $60     !10, '%24i%2B%2B'
         84        ASSIGN_DIM_OP                +=               1          $60, 'time'
         85        OP_DATA                                                  ~68
   26    86        FETCH_DIM_R                                      ~71     !10, '%2B%2B%24i'
         87        FETCH_DIM_R                                      ~72     ~71, !12
         88        FETCH_DIM_R                                      ~73     ~72, 'endTime'
         89        FETCH_DIM_R                                      ~74     !10, '%2B%2B%24i'
         90        FETCH_DIM_R                                      ~75     ~74, !12
         91        FETCH_DIM_R                                      ~76     ~75, 'startTime'
         92        SUB                                              ~77     ~73, ~76
         93        FETCH_DIM_RW                                     $69     !10, '%2B%2B%24i'
         94        ASSIGN_DIM_OP                +=               1          $69, 'time'
         95        OP_DATA                                                  ~77
   27    96        FETCH_DIM_R                                      ~80     !10, '%24i%2B%2B'
         97        FETCH_DIM_R                                      ~81     ~80, !12
         98        FETCH_DIM_R                                      ~82     ~81, 'endMemory'
         99        FETCH_DIM_R                                      ~83     !10, '%24i%2B%2B'
        100        FETCH_DIM_R                                      ~84     ~83, !12
        101        FETCH_DIM_R                                      ~85     ~84, 'startMemory'
        102        SUB                                              ~86     ~82, ~85
        103        FETCH_DIM_RW                                     $78     !10, '%24i%2B%2B'
        104        ASSIGN_DIM_OP                +=               1          $78, 'memory'
        105        OP_DATA                                                  ~86
   28   106        FETCH_DIM_R                                      ~89     !10, '%2B%2B%24i'
        107        FETCH_DIM_R                                      ~90     ~89, !12
        108        FETCH_DIM_R                                      ~91     ~90, 'endMemory'
        109        FETCH_DIM_R                                      ~92     !10, '%2B%2B%24i'
        110        FETCH_DIM_R                                      ~93     ~92, !12
        111        FETCH_DIM_R                                      ~94     ~93, 'startMemory'
        112        SUB                                              ~95     ~91, ~94
        113        FETCH_DIM_RW                                     $87     !10, '%2B%2B%24i'
        114        ASSIGN_DIM_OP                +=               1          $87, 'memory'
        115        OP_DATA                                                  ~95
   23   116        PRE_INC                                                  !12
        117    >   IS_SMALLER                                               !12, !0
        118      > JMPNZ                                                    ~97, ->76
   31   119    >   CONCAT                                           ~98     'There+were+', !0
        120        CONCAT                                           ~99     ~98, '+tests+conducted%2C+here%27s+the+totals%3Cbr+%2F%3E%3Cbr+%2F%3E%0A%24i%2B%2B+took+'
   32   121        FETCH_DIM_R                                      ~100    !10, '%24i%2B%2B'
        122        FETCH_DIM_R                                      ~101    ~100, 'time'
        123        CONCAT                                           ~102    ~99, ~101
        124        CONCAT                                           ~103    ~102, '+seconds+and+'
        125        FETCH_DIM_R                                      ~104    !10, '%24i%2B%2B'
        126        FETCH_DIM_R                                      ~105    ~104, 'memory'
        127        CONCAT                                           ~106    ~103, ~105
        128        CONCAT                                           ~107    ~106, '+bytes%3Cbr+%2F%3E%0A%2B%2B%24i+took+'
   33   129        FETCH_DIM_R                                      ~108    !10, '%2B%2B%24i'
        130        FETCH_DIM_R                                      ~109    ~108, 'time'
        131        CONCAT                                           ~110    ~107, ~109
        132        CONCAT                                           ~111    ~110, '+seconds+and+'
        133        FETCH_DIM_R                                      ~112    !10, '%2B%2B%24i'
        134        FETCH_DIM_R                                      ~113    ~112, 'memory'
        135        CONCAT                                           ~114    ~111, ~113
        136        CONCAT                                           ~115    ~114, '+bytes'
        137        ECHO                                                     ~115
        138      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.7 ms | 1408 KiB | 19 Q