3v4l.org

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

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.46 ms | 1408 KiB | 23 Q