3v4l.org

run code in 300+ PHP versions simultaneously
<?php function returnTime(callable $function, int $repeat = 50) { $tests = []; for ($i = 0; $i < $repeat; ++$i) { $startTime = microtime(true); $function(); $endTime = microtime(true); $tests[] = $endTime - $startTime; } // Representing the average return 1000 * array_sum($tests) / $repeat; } $array = range(0, 450000); unset($array[0]); echo "Duration of array_values: ", returnTime(function() use ($array) { $newArray = array_values($array); }); echo PHP_EOL; echo "Duration of splat-pack: " , returnTime(function() use ($array){ $newArray = [...$array]; });
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/N8hNN
function name:  (null)
number of ops:  22
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   INIT_FCALL                                               'range'
          1        SEND_VAL                                                 0
          2        SEND_VAL                                                 450000
          3        DO_ICALL                                         $1      
          4        ASSIGN                                                   !0, $1
   17     5        UNSET_DIM                                                !0, 0
   19     6        ECHO                                                     'Duration+of+array_values%3A+'
          7        INIT_FCALL                                               'returntime'
          8        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FN8hNN%3A19%240'
          9        BIND_LEXICAL                                             ~3, !0
   21    10        SEND_VAL                                                 ~3
         11        DO_FCALL                                      0  $4      
         12        ECHO                                                     $4
   23    13        ECHO                                                     '%0A'
   25    14        ECHO                                                     'Duration+of+splat-pack%3A+'
         15        INIT_FCALL                                               'returntime'
         16        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FN8hNN%3A25%241'
         17        BIND_LEXICAL                                             ~5, !0
   27    18        SEND_VAL                                                 ~5
         19        DO_FCALL                                      0  $6      
         20        ECHO                                                     $6
         21      > RETURN                                                   1

Function returntime:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
2 jumps found. (Code = 44) Position 1 = 21, Position 2 = 5
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
2 jumps found. (Code = 44) Position 1 = 21, Position 2 = 5
Branch analysis from position: 21
Branch analysis from position: 5
filename:       /in/N8hNN
function name:  returnTime
number of ops:  28
compiled vars:  !0 = $function, !1 = $repeat, !2 = $tests, !3 = $i, !4 = $startTime, !5 = $endTime
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      50
    4     2        ASSIGN                                                   !2, <array>
    6     3        ASSIGN                                                   !3, 0
          4      > JMP                                                      ->19
    7     5    >   INIT_FCALL                                               'microtime'
          6        SEND_VAL                                                 <true>
          7        DO_ICALL                                         $8      
          8        ASSIGN                                                   !4, $8
    8     9        INIT_DYNAMIC_CALL                                        !0
         10        DO_FCALL                                      0          
    9    11        INIT_FCALL                                               'microtime'
         12        SEND_VAL                                                 <true>
         13        DO_ICALL                                         $11     
         14        ASSIGN                                                   !5, $11
   10    15        SUB                                              ~14     !5, !4
         16        ASSIGN_DIM                                               !2
         17        OP_DATA                                                  ~14
    6    18        PRE_INC                                                  !3
         19    >   IS_SMALLER                                               !3, !1
         20      > JMPNZ                                                    ~16, ->5
   14    21    >   INIT_FCALL                                               'array_sum'
         22        SEND_VAR                                                 !2
         23        DO_ICALL                                         $17     
         24        MUL                                              ~18     $17, 1000
         25        DIV                                              ~19     ~18, !1
         26      > RETURN                                                   ~19
   15    27*     > RETURN                                                   null

End of function returntime

Function %00%7Bclosure%7D%2Fin%2FN8hNN%3A19%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/N8hNN
function name:  {closure}
number of ops:  6
compiled vars:  !0 = $array, !1 = $newArray
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   BIND_STATIC                                              !0
   20     1        INIT_FCALL                                               'array_values'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $2      
          4        ASSIGN                                                   !1, $2
   21     5      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FN8hNN%3A19%240

Function %00%7Bclosure%7D%2Fin%2FN8hNN%3A25%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/N8hNN
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $array, !1 = $newArray
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   BIND_STATIC                                              !0
   26     1        INIT_ARRAY                                       ~2      
          2        ADD_ARRAY_UNPACK                                 ~2      !0
          3        ASSIGN                                                   !1, ~2
   27     4      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FN8hNN%3A25%241

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
160.46 ms | 1403 KiB | 23 Q