3v4l.org

run code in 300+ PHP versions simultaneously
<?php function array_unpack(array $arg1, array $arg2) { return [...$arg1, ...$arg2]; } $arr1 = range(1, 100); $arr2 = array_combine(range('a', chr(ord('a') + 99)), range(1, 100)); $max = 10000; $start = microtime(true); for ($i = 0; $i < $max; $i++) { $res1 = array_merge($arr1, $arr2); } print("array_merge:\n"); printf("Took %.7f seconds per execution\n", (microtime(true) - $start) / $max); $max = 10000; $start = microtime(true); for ($i = 0; $i < $max; $i++) { $res2 = array_unpack($arr1, $arr2); } print("array_unpack:\n"); printf("Took %.7f seconds per execution\n", (microtime(true) - $start) / $max); assert($res1 === $res2);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 34
Branch analysis from position: 34
2 jumps found. (Code = 44) Position 1 = 36, Position 2 = 28
Branch analysis from position: 36
1 jumps found. (Code = 42) Position 1 = 59
Branch analysis from position: 59
2 jumps found. (Code = 44) Position 1 = 61, Position 2 = 53
Branch analysis from position: 61
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 53
2 jumps found. (Code = 44) Position 1 = 61, Position 2 = 53
Branch analysis from position: 61
Branch analysis from position: 53
Branch analysis from position: 28
2 jumps found. (Code = 44) Position 1 = 36, Position 2 = 28
Branch analysis from position: 36
Branch analysis from position: 28
filename:       /in/v5m9f
function name:  (null)
number of ops:  78
compiled vars:  !0 = $arr1, !1 = $arr2, !2 = $max, !3 = $start, !4 = $i, !5 = $res1, !6 = $res2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   INIT_FCALL                                               'range'
          1        SEND_VAL                                                 1
          2        SEND_VAL                                                 100
          3        DO_ICALL                                         $7      
          4        ASSIGN                                                   !0, $7
    9     5        INIT_FCALL                                               'array_combine'
          6        INIT_FCALL                                               'range'
          7        SEND_VAL                                                 'a'
          8        INIT_FCALL                                               'chr'
          9        SEND_VAL                                                 196
         10        DO_ICALL                                         $9      
         11        SEND_VAR                                                 $9
         12        DO_ICALL                                         $10     
         13        SEND_VAR                                                 $10
         14        INIT_FCALL                                               'range'
         15        SEND_VAL                                                 1
         16        SEND_VAL                                                 100
         17        DO_ICALL                                         $11     
         18        SEND_VAR                                                 $11
         19        DO_ICALL                                         $12     
         20        ASSIGN                                                   !1, $12
   11    21        ASSIGN                                                   !2, 10000
   12    22        INIT_FCALL                                               'microtime'
         23        SEND_VAL                                                 <true>
         24        DO_ICALL                                         $15     
         25        ASSIGN                                                   !3, $15
   13    26        ASSIGN                                                   !4, 0
         27      > JMP                                                      ->34
   14    28    >   INIT_FCALL                                               'array_merge'
         29        SEND_VAR                                                 !0
         30        SEND_VAR                                                 !1
         31        DO_ICALL                                         $18     
         32        ASSIGN                                                   !5, $18
   13    33        PRE_INC                                                  !4
         34    >   IS_SMALLER                                               !4, !2
         35      > JMPNZ                                                    ~21, ->28
   16    36    >   ECHO                                                     'array_merge%3A%0A'
   17    37        INIT_FCALL                                               'printf'
         38        SEND_VAL                                                 'Took+%25.7f+seconds+per+execution%0A'
         39        INIT_FCALL                                               'microtime'
         40        SEND_VAL                                                 <true>
         41        DO_ICALL                                         $22     
         42        SUB                                              ~23     $22, !3
         43        DIV                                              ~24     ~23, !2
         44        SEND_VAL                                                 ~24
         45        DO_ICALL                                                 
   19    46        ASSIGN                                                   !2, 10000
   20    47        INIT_FCALL                                               'microtime'
         48        SEND_VAL                                                 <true>
         49        DO_ICALL                                         $27     
         50        ASSIGN                                                   !3, $27
   21    51        ASSIGN                                                   !4, 0
         52      > JMP                                                      ->59
   22    53    >   INIT_FCALL                                               'array_unpack'
         54        SEND_VAR                                                 !0
         55        SEND_VAR                                                 !1
         56        DO_FCALL                                      0  $30     
         57        ASSIGN                                                   !6, $30
   21    58        PRE_INC                                                  !4
         59    >   IS_SMALLER                                               !4, !2
         60      > JMPNZ                                                    ~33, ->53
   24    61    >   ECHO                                                     'array_unpack%3A%0A'
   25    62        INIT_FCALL                                               'printf'
         63        SEND_VAL                                                 'Took+%25.7f+seconds+per+execution%0A'
         64        INIT_FCALL                                               'microtime'
         65        SEND_VAL                                                 <true>
         66        DO_ICALL                                         $34     
         67        SUB                                              ~35     $34, !3
         68        DIV                                              ~36     ~35, !2
         69        SEND_VAL                                                 ~36
         70        DO_ICALL                                                 
   27    71        ASSERT_CHECK                                             
         72        INIT_FCALL                                               'assert'
         73        IS_IDENTICAL                                     ~38     !5, !6
         74        SEND_VAL                                                 ~38
         75        SEND_VAL                                                 'assert%28%24res1+%3D%3D%3D+%24res2%29'
         76        DO_ICALL                                                 
         77      > RETURN                                                   1

Function array_unpack:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/v5m9f
function name:  array_unpack
number of ops:  7
compiled vars:  !0 = $arg1, !1 = $arg2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    5     2        INIT_ARRAY                                       ~2      
          3        ADD_ARRAY_UNPACK                                 ~2      !0
          4        ADD_ARRAY_UNPACK                                 ~2      !1
          5      > RETURN                                                   ~2
    6     6*     > RETURN                                                   null

End of function array_unpack

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
139.83 ms | 1016 KiB | 21 Q