3v4l.org

run code in 300+ PHP versions simultaneously
<?php $numbers = range(32, 127); $numbersLetters = array_map('chr', $numbers); for (;;) { $numbersLetters = array_merge($numbersLetters, $numbersLetters); if (count($numbersLetters) > 1000) { break; } } $numbers = range(1, count($numbersLetters)); printf("Sample size: %d elements in 2 arrays (%d total) \n", count($numbers), count($numbers) + count($numbersLetters)); // =============================------------=============================== printf("Benchmarking speed in foreach + in_array() scenario... (this might take a while) "); shuffle($numbers); shuffle($numbersLetters); $t1 = microtime(true); foreach ($numbers as $number) { if (in_array($number, $numbersLetters)) {} } $t2 = microtime(true); printf("DONE!\n"); printf("Time elapsed: %.5f \n", $t2 - $t1); // =============================------------=============================== printf("Benchmarking speed with array_intersect..."); shuffle($numbers); shuffle($numbersLetters); $t1 = microtime(true); array_intersect($numbers, $numbersLetters); $t2 = microtime(true); printf("DONE!\n"); printf("Time elapsed: %.5f \n", $t2 - $t1);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
2 jumps found. (Code = 44) Position 1 = 21, Position 2 = 11
Branch analysis from position: 21
2 jumps found. (Code = 77) Position 1 = 50, Position 2 = 57
Branch analysis from position: 50
2 jumps found. (Code = 78) Position 1 = 51, Position 2 = 57
Branch analysis from position: 51
2 jumps found. (Code = 43) Position 1 = 56, Position 2 = 56
Branch analysis from position: 56
1 jumps found. (Code = 42) Position 1 = 50
Branch analysis from position: 50
Branch analysis from position: 56
Branch analysis from position: 57
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 57
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 20
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
Branch analysis from position: 20
filename:       /in/Lcu3r
function name:  (null)
number of ops:  100
compiled vars:  !0 = $numbers, !1 = $numbersLetters, !2 = $t1, !3 = $number, !4 = $t2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   INIT_FCALL                                               'range'
          1        SEND_VAL                                                 32
          2        SEND_VAL                                                 127
          3        DO_ICALL                                         $5      
          4        ASSIGN                                                   !0, $5
    3     5        INIT_FCALL                                               'array_map'
          6        SEND_VAL                                                 'chr'
          7        SEND_VAR                                                 !0
          8        DO_ICALL                                         $7      
          9        ASSIGN                                                   !1, $7
    5    10      > JMP                                                      ->20
    6    11    >   INIT_FCALL                                               'array_merge'
         12        SEND_VAR                                                 !1
         13        SEND_VAR                                                 !1
         14        DO_ICALL                                         $9      
         15        ASSIGN                                                   !1, $9
    8    16        COUNT                                            ~11     !1
         17        IS_SMALLER                                               1000, ~11
         18      > JMPZ                                                     ~12, ->20
    9    19    > > JMP                                                      ->21
         20    > > JMPNZ                                                    <true>, ->11
   13    21    >   INIT_FCALL                                               'range'
         22        SEND_VAL                                                 1
         23        COUNT                                            ~13     !1
         24        SEND_VAL                                                 ~13
         25        DO_ICALL                                         $14     
         26        ASSIGN                                                   !0, $14
   15    27        INIT_FCALL                                               'printf'
         28        SEND_VAL                                                 'Sample+size%3A+%25d+elements+in+2+arrays+%28%25d+total%29+%0A'
         29        COUNT                                            ~16     !0
         30        SEND_VAL                                                 ~16
         31        COUNT                                            ~17     !0
         32        COUNT                                            ~18     !1
         33        ADD                                              ~19     ~17, ~18
         34        SEND_VAL                                                 ~19
         35        DO_ICALL                                                 
   19    36        INIT_FCALL                                               'printf'
         37        SEND_VAL                                                 'Benchmarking+speed+in+foreach+%2B+in_array%28%29+scenario...+%28this+might+take+a+while%29+'
         38        DO_ICALL                                                 
   21    39        INIT_FCALL                                               'shuffle'
         40        SEND_REF                                                 !0
         41        DO_ICALL                                                 
   22    42        INIT_FCALL                                               'shuffle'
         43        SEND_REF                                                 !1
         44        DO_ICALL                                                 
   24    45        INIT_FCALL                                               'microtime'
         46        SEND_VAL                                                 <true>
         47        DO_ICALL                                         $24     
         48        ASSIGN                                                   !2, $24
   26    49      > FE_RESET_R                                       $26     !0, ->57
         50    > > FE_FETCH_R                                               $26, !3, ->57
   27    51    >   INIT_FCALL                                               'in_array'
         52        SEND_VAR                                                 !3
         53        SEND_VAR                                                 !1
         54        DO_ICALL                                         $27     
         55      > JMPZ                                                     $27, ->56
   26    56    > > JMP                                                      ->50
         57    >   FE_FREE                                                  $26
   30    58        INIT_FCALL                                               'microtime'
         59        SEND_VAL                                                 <true>
         60        DO_ICALL                                         $28     
         61        ASSIGN                                                   !4, $28
   32    62        INIT_FCALL                                               'printf'
         63        SEND_VAL                                                 'DONE%21%0A'
         64        DO_ICALL                                                 
   33    65        INIT_FCALL                                               'printf'
         66        SEND_VAL                                                 'Time+elapsed%3A+%25.5f+%0A'
         67        SUB                                              ~31     !4, !2
         68        SEND_VAL                                                 ~31
         69        DO_ICALL                                                 
   37    70        INIT_FCALL                                               'printf'
         71        SEND_VAL                                                 'Benchmarking+speed+with+array_intersect...'
         72        DO_ICALL                                                 
   39    73        INIT_FCALL                                               'shuffle'
         74        SEND_REF                                                 !0
         75        DO_ICALL                                                 
   40    76        INIT_FCALL                                               'shuffle'
         77        SEND_REF                                                 !1
         78        DO_ICALL                                                 
   42    79        INIT_FCALL                                               'microtime'
         80        SEND_VAL                                                 <true>
         81        DO_ICALL                                         $36     
         82        ASSIGN                                                   !2, $36
   44    83        INIT_FCALL                                               'array_intersect'
         84        SEND_VAR                                                 !0
         85        SEND_VAR                                                 !1
         86        DO_ICALL                                                 
   46    87        INIT_FCALL                                               'microtime'
         88        SEND_VAL                                                 <true>
         89        DO_ICALL                                         $39     
         90        ASSIGN                                                   !4, $39
   48    91        INIT_FCALL                                               'printf'
         92        SEND_VAL                                                 'DONE%21%0A'
         93        DO_ICALL                                                 
   49    94        INIT_FCALL                                               'printf'
         95        SEND_VAL                                                 'Time+elapsed%3A+%25.5f+%0A'
         96        SUB                                              ~42     !4, !2
         97        SEND_VAL                                                 ~42
         98        DO_ICALL                                                 
         99      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.9 ms | 1404 KiB | 29 Q