3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = range(0, 1000, 1); $benchmarks = []; $runs = 100; $callback = function ($item) { return $item * 2; }; $benchmarks['map_closure'] = function ($array) use ($callback) { return array_map($callback, $array); }; foreach ($benchmarks as $code => $callable) { $start = microtime(true); $collected = 0; while ($collected < $runs) { $collected++; $callable($array); } $end = microtime(true); printf('%s runs in %ss %s', $code, $end - $start, PHP_EOL); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 15, Position 2 = 41
Branch analysis from position: 15
2 jumps found. (Code = 78) Position 1 = 16, Position 2 = 41
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 27
Branch analysis from position: 27
2 jumps found. (Code = 44) Position 1 = 29, Position 2 = 23
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
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: 41
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 41
filename:       /in/5e0b0
function name:  (null)
number of ops:  43
compiled vars:  !0 = $array, !1 = $benchmarks, !2 = $runs, !3 = $callback, !4 = $callable, !5 = $code, !6 = $start, !7 = $collected, !8 = $end
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'range'
          1        SEND_VAL                                                 0
          2        SEND_VAL                                                 1000
          3        SEND_VAL                                                 1
          4        DO_ICALL                                         $9      
          5        ASSIGN                                                   !0, $9
    4     6        ASSIGN                                                   !1, <array>
    6     7        ASSIGN                                                   !2, 100
    9     8        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F5e0b0%3A9%240'
          9        ASSIGN                                                   !3, ~13
   12    10        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F5e0b0%3A12%241'
         11        BIND_LEXICAL                                             ~16, !3
         12        ASSIGN_DIM                                               !1, 'map_closure'
   14    13        OP_DATA                                                  ~16
   16    14      > FE_RESET_R                                       $17     !1, ->41
         15    > > FE_FETCH_R                                       ~18     $17, !4, ->41
         16    >   ASSIGN                                                   !5, ~18
   18    17        INIT_FCALL                                               'microtime'
         18        SEND_VAL                                                 <true>
         19        DO_ICALL                                         $20     
         20        ASSIGN                                                   !6, $20
   19    21        ASSIGN                                                   !7, 0
   20    22      > JMP                                                      ->27
   21    23    >   PRE_INC                                                  !7
   22    24        INIT_DYNAMIC_CALL                                        !4
         25        SEND_VAR_EX                                              !0
         26        DO_FCALL                                      0          
   20    27    >   IS_SMALLER                                               !7, !2
         28      > JMPNZ                                                    ~25, ->23
   24    29    >   INIT_FCALL                                               'microtime'
         30        SEND_VAL                                                 <true>
         31        DO_ICALL                                         $26     
         32        ASSIGN                                                   !8, $26
   26    33        INIT_FCALL                                               'printf'
         34        SEND_VAL                                                 '%25s+runs+in+%25ss+%25s'
         35        SEND_VAR                                                 !5
         36        SUB                                              ~28     !8, !6
         37        SEND_VAL                                                 ~28
         38        SEND_VAL                                                 '%0A'
         39        DO_ICALL                                                 
   16    40      > JMP                                                      ->15
         41    >   FE_FREE                                                  $17
   27    42      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2F5e0b0%3A9%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/5e0b0
function name:  {closure}
number of ops:  4
compiled vars:  !0 = $item
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
   10     1        MUL                                              ~1      !0, 2
          2      > RETURN                                                   ~1
   11     3*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F5e0b0%3A9%240

Function %00%7Bclosure%7D%2Fin%2F5e0b0%3A12%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/5e0b0
function name:  {closure}
number of ops:  8
compiled vars:  !0 = $array, !1 = $callback
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   13     2        INIT_FCALL                                               'array_map'
          3        SEND_VAR                                                 !1
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $2      
          6      > RETURN                                                   $2
   14     7*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F5e0b0%3A12%241

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
144.17 ms | 1411 KiB | 21 Q