3v4l.org

run code in 300+ PHP versions simultaneously
<?php $loop = 100000; $s = 'a'; $t = 'b'; function t($p1, $p2) { return $p1.$p1; } $f1 = function() use ($s, $t) { return $s.$t; }; $f2 = function($s, $t) { return $s.$t; }; $tmp = $loop; $start = microtime(true); while($tmp--) { $r = t($s, $t); } echo 'Function: '. (microtime(true) - $start). "\n\n"; $tmp = $loop; $start = microtime(true); while($tmp--) { $r = $f1(); } echo 'Closure(use): '. (microtime(true) - $start). "\n\n"; $tmp = $loop; $start = microtime(true); while($tmp--) { $r = $f2($s, $t); } echo 'Closure(param): '. (microtime(true) - $start). "\n\n";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
2 jumps found. (Code = 44) Position 1 = 22, Position 2 = 15
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 38
Branch analysis from position: 38
2 jumps found. (Code = 44) Position 1 = 40, Position 2 = 35
Branch analysis from position: 40
1 jumps found. (Code = 42) Position 1 = 58
Branch analysis from position: 58
2 jumps found. (Code = 44) Position 1 = 60, Position 2 = 53
Branch analysis from position: 60
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 53
2 jumps found. (Code = 44) Position 1 = 60, Position 2 = 53
Branch analysis from position: 60
Branch analysis from position: 53
Branch analysis from position: 35
2 jumps found. (Code = 44) Position 1 = 40, Position 2 = 35
Branch analysis from position: 40
Branch analysis from position: 35
Branch analysis from position: 15
2 jumps found. (Code = 44) Position 1 = 22, Position 2 = 15
Branch analysis from position: 22
Branch analysis from position: 15
filename:       /in/ltJ3m
function name:  (null)
number of ops:  68
compiled vars:  !0 = $loop, !1 = $s, !2 = $t, !3 = $f1, !4 = $f2, !5 = $tmp, !6 = $start, !7 = $r
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, 100000
    4     1        ASSIGN                                                   !1, 'a'
    5     2        ASSIGN                                                   !2, 'b'
   11     3        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FltJ3m%3A11%240'
          4        BIND_LEXICAL                                             ~11, !1
          5        BIND_LEXICAL                                             ~11, !2
          6        ASSIGN                                                   !3, ~11
   15     7        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FltJ3m%3A15%241'
          8        ASSIGN                                                   !4, ~13
   20     9        ASSIGN                                                   !5, !0
   21    10        INIT_FCALL                                               'microtime'
         11        SEND_VAL                                                 <true>
         12        DO_ICALL                                         $16     
         13        ASSIGN                                                   !6, $16
   22    14      > JMP                                                      ->20
   23    15    >   INIT_FCALL                                               't'
         16        SEND_VAR                                                 !1
         17        SEND_VAR                                                 !2
         18        DO_FCALL                                      0  $18     
         19        ASSIGN                                                   !7, $18
   22    20    >   POST_DEC                                         ~20     !5
         21      > JMPNZ                                                    ~20, ->15
   25    22    >   INIT_FCALL                                               'microtime'
         23        SEND_VAL                                                 <true>
         24        DO_ICALL                                         $21     
         25        SUB                                              ~22     $21, !6
         26        CONCAT                                           ~23     'Function%3A+', ~22
         27        CONCAT                                           ~24     ~23, '%0A%0A'
         28        ECHO                                                     ~24
   28    29        ASSIGN                                                   !5, !0
   29    30        INIT_FCALL                                               'microtime'
         31        SEND_VAL                                                 <true>
         32        DO_ICALL                                         $26     
         33        ASSIGN                                                   !6, $26
   30    34      > JMP                                                      ->38
   31    35    >   INIT_DYNAMIC_CALL                                        !3
         36        DO_FCALL                                      0  $28     
         37        ASSIGN                                                   !7, $28
   30    38    >   POST_DEC                                         ~30     !5
         39      > JMPNZ                                                    ~30, ->35
   33    40    >   INIT_FCALL                                               'microtime'
         41        SEND_VAL                                                 <true>
         42        DO_ICALL                                         $31     
         43        SUB                                              ~32     $31, !6
         44        CONCAT                                           ~33     'Closure%28use%29%3A+', ~32
         45        CONCAT                                           ~34     ~33, '%0A%0A'
         46        ECHO                                                     ~34
   35    47        ASSIGN                                                   !5, !0
   36    48        INIT_FCALL                                               'microtime'
         49        SEND_VAL                                                 <true>
         50        DO_ICALL                                         $36     
         51        ASSIGN                                                   !6, $36
   37    52      > JMP                                                      ->58
   38    53    >   INIT_DYNAMIC_CALL                                        !4
         54        SEND_VAR_EX                                              !1
         55        SEND_VAR_EX                                              !2
         56        DO_FCALL                                      0  $38     
         57        ASSIGN                                                   !7, $38
   37    58    >   POST_DEC                                         ~40     !5
         59      > JMPNZ                                                    ~40, ->53
   40    60    >   INIT_FCALL                                               'microtime'
         61        SEND_VAL                                                 <true>
         62        DO_ICALL                                         $41     
         63        SUB                                              ~42     $41, !6
         64        CONCAT                                           ~43     'Closure%28param%29%3A+', ~42
         65        CONCAT                                           ~44     ~43, '%0A%0A'
         66        ECHO                                                     ~44
         67      > RETURN                                                   1

Function t:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ltJ3m
function name:  t
number of ops:  5
compiled vars:  !0 = $p1, !1 = $p2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    8     2        CONCAT                                           ~2      !0, !0
          3      > RETURN                                                   ~2
    9     4*     > RETURN                                                   null

End of function t

Function %00%7Bclosure%7D%2Fin%2FltJ3m%3A11%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ltJ3m
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $s, !1 = $t
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   BIND_STATIC                                              !0
          1        BIND_STATIC                                              !1
   12     2        CONCAT                                           ~2      !0, !1
          3      > RETURN                                                   ~2
   13     4*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FltJ3m%3A11%240

Function %00%7Bclosure%7D%2Fin%2FltJ3m%3A15%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ltJ3m
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $s, !1 = $t
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   16     2        CONCAT                                           ~2      !0, !1
          3      > RETURN                                                   ~2
   17     4*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FltJ3m%3A15%241

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.51 ms | 1407 KiB | 16 Q