3v4l.org

run code in 300+ PHP versions simultaneously
<?php function arraydiff(&$array1, &$array2) { $a1 = array_flip($array1); $a2 = array_flip($array2); $differences = array(); //what is in array 1 that is not in array2 $c = count($a1); foreach ($a1 as $k => $v) { if (!isset($a2[$k])) { $differences[] = $k; } } return $differences; } $i=0; $j=500000; while($i < 60000) { $i++; $j++; $data1[] = md5($i); $data2[] = md5($j); } $time = microtime(true); echo "Starting arraydiff\n"; $data_diff1 = arraydiff($data1, $data2); $time = microtime(true) - $time; echo 'arraydiff() took ' . number_format($time, 3) . ' seconds and returned ' . count($data_diff1) . " entries\n";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
2 jumps found. (Code = 44) Position 1 = 17, Position 2 = 3
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 3
2 jumps found. (Code = 44) Position 1 = 17, Position 2 = 3
Branch analysis from position: 17
Branch analysis from position: 3
filename:       /in/BltNP
function name:  (null)
number of ops:  43
compiled vars:  !0 = $i, !1 = $j, !2 = $data1, !3 = $data2, !4 = $time, !5 = $data_diff1
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   ASSIGN                                                   !0, 0
          1        ASSIGN                                                   !1, 500000
   19     2      > JMP                                                      ->15
   20     3    >   PRE_INC                                                  !0
          4        PRE_INC                                                  !1
   21     5        INIT_FCALL                                               'md5'
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                         $11     
          8        ASSIGN_DIM                                               !2
          9        OP_DATA                                                  $11
   22    10        INIT_FCALL                                               'md5'
         11        SEND_VAR                                                 !1
         12        DO_ICALL                                         $13     
         13        ASSIGN_DIM                                               !3
         14        OP_DATA                                                  $13
   19    15    >   IS_SMALLER                                               !0, 60000
         16      > JMPNZ                                                    ~14, ->3
   25    17    >   INIT_FCALL                                               'microtime'
         18        SEND_VAL                                                 <true>
         19        DO_ICALL                                         $15     
         20        ASSIGN                                                   !4, $15
   27    21        ECHO                                                     'Starting+arraydiff%0A'
   28    22        INIT_FCALL                                               'arraydiff'
         23        SEND_REF                                                 !2
         24        SEND_REF                                                 !3
         25        DO_FCALL                                      0  $17     
         26        ASSIGN                                                   !5, $17
   30    27        INIT_FCALL                                               'microtime'
         28        SEND_VAL                                                 <true>
         29        DO_ICALL                                         $19     
         30        SUB                                              ~20     $19, !4
         31        ASSIGN                                                   !4, ~20
   32    32        INIT_FCALL                                               'number_format'
         33        SEND_VAR                                                 !4
         34        SEND_VAL                                                 3
         35        DO_ICALL                                         $22     
         36        CONCAT                                           ~23     'arraydiff%28%29+took+', $22
         37        CONCAT                                           ~24     ~23, '+seconds+and+returned+'
         38        COUNT                                            ~25     !5
         39        CONCAT                                           ~26     ~24, ~25
         40        CONCAT                                           ~27     ~26, '+entries%0A'
         41        ECHO                                                     ~27
         42      > RETURN                                                   1

Function arraydiff:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 14, Position 2 = 22
Branch analysis from position: 14
2 jumps found. (Code = 78) Position 1 = 15, Position 2 = 22
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 21
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
Branch analysis from position: 21
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
filename:       /in/BltNP
function name:  arraydiff
number of ops:  25
compiled vars:  !0 = $array1, !1 = $array2, !2 = $a1, !3 = $a2, !4 = $differences, !5 = $c, !6 = $v, !7 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    4     2        INIT_FCALL                                               'array_flip'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $8      
          5        ASSIGN                                                   !2, $8
    5     6        INIT_FCALL                                               'array_flip'
          7        SEND_VAR                                                 !1
          8        DO_ICALL                                         $10     
          9        ASSIGN                                                   !3, $10
    7    10        ASSIGN                                                   !4, <array>
    8    11        COUNT                                            ~13     !2
         12        ASSIGN                                                   !5, ~13
   10    13      > FE_RESET_R                                       $15     !2, ->22
         14    > > FE_FETCH_R                                       ~16     $15, !6, ->22
         15    >   ASSIGN                                                   !7, ~16
   11    16        ISSET_ISEMPTY_DIM_OBJ                         0  ~18     !3, !7
         17        BOOL_NOT                                         ~19     ~18
         18      > JMPZ                                                     ~19, ->21
   12    19    >   ASSIGN_DIM                                               !4
         20        OP_DATA                                                  !7
   10    21    > > JMP                                                      ->14
         22    >   FE_FREE                                                  $15
   15    23      > RETURN                                                   !4
   16    24*     > RETURN                                                   null

End of function arraydiff

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.47 ms | 1403 KiB | 22 Q