3v4l.org

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

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
140.97 ms | 1400 KiB | 17 Q