3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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); }
based on ohVb1
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 15, Position 2 = 42
Branch analysis from position: 15
2 jumps found. (Code = 78) Position 1 = 16, Position 2 = 42
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 28
Branch analysis from position: 28
2 jumps found. (Code = 44) Position 1 = 30, Position 2 = 23
Branch analysis from position: 30
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 = 30, Position 2 = 23
Branch analysis from position: 30
Branch analysis from position: 23
Branch analysis from position: 42
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 42
filename:       /in/5e0b0
function name:  (null)
number of ops:  44
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%2F5e0b00x7fa68238407a'
  11     9        ASSIGN                                                   !3, ~13
  12    10        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F5e0b00x7fa6823840e7'
        11        BIND_LEXICAL                                             ~16, !3
        12        ASSIGN_DIM                                               !1, 'map_closure'
  14    13        OP_DATA                                                  ~16
  16    14      > FE_RESET_R                                       $17     !1, ->42
        15    > > FE_FETCH_R                                       ~18     $17, !4, ->42
        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                                                      ->28
  21    23    >   POST_INC                                         ~23     !7
        24        FREE                                                     ~23
  22    25        INIT_DYNAMIC_CALL                                        !4
        26        SEND_VAR_EX                                              !0
        27        DO_FCALL                                      0          
  20    28    >   IS_SMALLER                                       ~25     !7, !2
        29      > JMPNZ                                                    ~25, ->23
  24    30    >   INIT_FCALL                                               'microtime'
        31        SEND_VAL                                                 <true>
        32        DO_ICALL                                         $26     
        33        ASSIGN                                                   !8, $26
  26    34        INIT_FCALL                                               'printf'
        35        SEND_VAL                                                 '%25s+runs+in+%25ss+%25s'
        36        SEND_VAR                                                 !5
        37        SUB                                              ~28     !8, !6
        38        SEND_VAL                                                 ~28
        39        SEND_VAL                                                 '%0A'
        40        DO_ICALL                                                 
        41      > JMP                                                      ->15
        42    >   FE_FREE                                                  $17
  27    43      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2F5e0b00x7fa68238407a:
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%2F5e0b00x7fa68238407a

Function %00%7Bclosure%7D%2Fin%2F5e0b00x7fa6823840e7:
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, 'callback'
  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%2F5e0b00x7fa6823840e7

Generated using Vulcan Logic Dumper, using php 7.3.0