3v4l.org

run code in 300+ PHP versions simultaneously
<?php const INT_COUNT = 1000000; // Fill an array with random ints $ints = array(); for ($i = 0; $i < INT_COUNT; $i++){ $ints[] = rand(0, 255); } // Sort the ints sort($ints); $start = microtime(true); // Do nothing but access each int in the array for ($i = 0; $i < INT_COUNT; $i++){ $ints[$i]; } $finish = microtime(true); printf("Time taken with sort(): %.5f seconds\n", $finish - $start); // Now do it again, but this time use an asort // Fill an array with random ints $ints2 = array(); for ($i = 0; $i < INT_COUNT; $i++){ $ints2[] = rand(0, 255); } // asort the ints asort($ints2); $start = microtime(true); // Do nothing but access each int in the array for ($i = 0; $i < INT_COUNT; $i++){ $ints2[$i]; } $finish = microtime(true); printf("Time taken with asort(): %.5f seconds\n", $finish - $start);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
2 jumps found. (Code = 44) Position 1 = 14, Position 2 = 4
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
2 jumps found. (Code = 44) Position 1 = 29, Position 2 = 23
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 48
Branch analysis from position: 48
2 jumps found. (Code = 44) Position 1 = 51, Position 2 = 41
Branch analysis from position: 51
1 jumps found. (Code = 42) Position 1 = 63
Branch analysis from position: 63
2 jumps found. (Code = 44) Position 1 = 66, Position 2 = 60
Branch analysis from position: 66
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 60
2 jumps found. (Code = 44) Position 1 = 66, Position 2 = 60
Branch analysis from position: 66
Branch analysis from position: 60
Branch analysis from position: 41
2 jumps found. (Code = 44) Position 1 = 51, Position 2 = 41
Branch analysis from position: 51
Branch analysis from position: 41
Branch analysis from position: 23
2 jumps found. (Code = 44) Position 1 = 29, Position 2 = 23
Branch analysis from position: 29
Branch analysis from position: 23
Branch analysis from position: 4
2 jumps found. (Code = 44) Position 1 = 14, Position 2 = 4
Branch analysis from position: 14
Branch analysis from position: 4
filename:       /in/sRQXr
function name:  (null)
number of ops:  76
compiled vars:  !0 = $ints, !1 = $i, !2 = $start, !3 = $finish, !4 = $ints2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CONST                                            'INT_COUNT', 1000000
    6     1        ASSIGN                                                   !0, <array>
    7     2        ASSIGN                                                   !1, 0
          3      > JMP                                                      ->11
    8     4    >   INIT_FCALL                                               'rand'
          5        SEND_VAL                                                 0
          6        SEND_VAL                                                 255
          7        DO_ICALL                                         $8      
          8        ASSIGN_DIM                                               !0
          9        OP_DATA                                                  $8
    7    10        PRE_INC                                                  !1
         11    >   FETCH_CONSTANT                                   ~10     'INT_COUNT'
         12        IS_SMALLER                                               !1, ~10
         13      > JMPNZ                                                    ~11, ->4
   12    14    >   INIT_FCALL                                               'sort'
         15        SEND_REF                                                 !0
         16        DO_ICALL                                                 
   14    17        INIT_FCALL                                               'microtime'
         18        SEND_VAL                                                 <true>
         19        DO_ICALL                                         $13     
         20        ASSIGN                                                   !2, $13
   17    21        ASSIGN                                                   !1, 0
         22      > JMP                                                      ->26
   18    23    >   FETCH_DIM_R                                      ~16     !0, !1
         24        FREE                                                     ~16
   17    25        PRE_INC                                                  !1
         26    >   FETCH_CONSTANT                                   ~18     'INT_COUNT'
         27        IS_SMALLER                                               !1, ~18
         28      > JMPNZ                                                    ~19, ->23
   21    29    >   INIT_FCALL                                               'microtime'
         30        SEND_VAL                                                 <true>
         31        DO_ICALL                                         $20     
         32        ASSIGN                                                   !3, $20
   22    33        INIT_FCALL                                               'printf'
         34        SEND_VAL                                                 'Time+taken+with+sort%28%29%3A+%25.5f+seconds%0A'
         35        SUB                                              ~22     !3, !2
         36        SEND_VAL                                                 ~22
         37        DO_ICALL                                                 
   29    38        ASSIGN                                                   !4, <array>
   30    39        ASSIGN                                                   !1, 0
         40      > JMP                                                      ->48
   31    41    >   INIT_FCALL                                               'rand'
         42        SEND_VAL                                                 0
         43        SEND_VAL                                                 255
         44        DO_ICALL                                         $27     
         45        ASSIGN_DIM                                               !4
         46        OP_DATA                                                  $27
   30    47        PRE_INC                                                  !1
         48    >   FETCH_CONSTANT                                   ~29     'INT_COUNT'
         49        IS_SMALLER                                               !1, ~29
         50      > JMPNZ                                                    ~30, ->41
   35    51    >   INIT_FCALL                                               'asort'
         52        SEND_REF                                                 !4
         53        DO_ICALL                                                 
   37    54        INIT_FCALL                                               'microtime'
         55        SEND_VAL                                                 <true>
         56        DO_ICALL                                         $32     
         57        ASSIGN                                                   !2, $32
   40    58        ASSIGN                                                   !1, 0
         59      > JMP                                                      ->63
   41    60    >   FETCH_DIM_R                                      ~35     !4, !1
         61        FREE                                                     ~35
   40    62        PRE_INC                                                  !1
         63    >   FETCH_CONSTANT                                   ~37     'INT_COUNT'
         64        IS_SMALLER                                               !1, ~37
         65      > JMPNZ                                                    ~38, ->60
   44    66    >   INIT_FCALL                                               'microtime'
         67        SEND_VAL                                                 <true>
         68        DO_ICALL                                         $39     
         69        ASSIGN                                                   !3, $39
   45    70        INIT_FCALL                                               'printf'
         71        SEND_VAL                                                 'Time+taken+with+asort%28%29%3A+%25.5f+seconds%0A'
         72        SUB                                              ~41     !3, !2
         73        SEND_VAL                                                 ~41
         74        DO_ICALL                                                 
         75      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.73 ms | 1392 KiB | 23 Q