3v4l.org

run code in 300+ PHP versions simultaneously
<?php $start = microtime(true); $fn = @create_function('$a,$b', 'return log($a * $b);'); $v = 0; for ($i = 0; $i < 1000; $i++) $v += $fn($i, $i); echo("create_function: " . (microtime(true) - $start) . "\n"); $start = microtime(true); $v = 0; for ($i = 0; $i < 1000; $i++) $v += eval("return log($i * $i);"); echo("eval: " . (microtime(true) - $start) . "\n"); $start = microtime(true); $fn = fn($a, $b) => log($a * $b); $v = 0; for ($i = 0; $i < 1000; $i++) $v += $fn($i, $i); echo("arrow function: " . (microtime(true) - $start) . "\n"); $start = microtime(true); $fn = function ($a, $b) { return log($a * $b); }; $v = 0; for ($i = 0; $i < 1000; $i++) $v += $fn($i, $i); echo("anonymous function: " . (microtime(true) - $start) . "\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 = 14
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 44
Branch analysis from position: 44
2 jumps found. (Code = 44) Position 1 = 46, Position 2 = 36
Branch analysis from position: 46
1 jumps found. (Code = 42) Position 1 = 68
Branch analysis from position: 68
2 jumps found. (Code = 44) Position 1 = 70, Position 2 = 62
Branch analysis from position: 70
1 jumps found. (Code = 42) Position 1 = 92
Branch analysis from position: 92
2 jumps found. (Code = 44) Position 1 = 94, Position 2 = 86
Branch analysis from position: 94
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 86
2 jumps found. (Code = 44) Position 1 = 94, Position 2 = 86
Branch analysis from position: 94
Branch analysis from position: 86
Branch analysis from position: 62
2 jumps found. (Code = 44) Position 1 = 70, Position 2 = 62
Branch analysis from position: 70
Branch analysis from position: 62
Branch analysis from position: 36
2 jumps found. (Code = 44) Position 1 = 46, Position 2 = 36
Branch analysis from position: 46
Branch analysis from position: 36
Branch analysis from position: 14
2 jumps found. (Code = 44) Position 1 = 22, Position 2 = 14
Branch analysis from position: 22
Branch analysis from position: 14
filename:       /in/8euWR
function name:  (null)
number of ops:  102
compiled vars:  !0 = $start, !1 = $fn, !2 = $v, !3 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'microtime'
          1        SEND_VAL                                                 <true>
          2        DO_ICALL                                         $4      
          3        ASSIGN                                                   !0, $4
    4     4        BEGIN_SILENCE                                    ~6      
          5        INIT_FCALL_BY_NAME                                       'create_function'
          6        SEND_VAL_EX                                              '%24a%2C%24b'
          7        SEND_VAL_EX                                              'return+log%28%24a+%2A+%24b%29%3B'
          8        DO_FCALL                                      0  $7      
          9        END_SILENCE                                              ~6
         10        ASSIGN                                                   !1, $7
    5    11        ASSIGN                                                   !2, 0
    6    12        ASSIGN                                                   !3, 0
         13      > JMP                                                      ->20
    7    14    >   INIT_DYNAMIC_CALL                                        !1
         15        SEND_VAR_EX                                              !3
         16        SEND_VAR_EX                                              !3
         17        DO_FCALL                                      0  $11     
         18        ASSIGN_OP                                     1          !2, $11
    6    19        PRE_INC                                                  !3
         20    >   IS_SMALLER                                               !3, 1000
         21      > JMPNZ                                                    ~14, ->14
    8    22    >   INIT_FCALL                                               'microtime'
         23        SEND_VAL                                                 <true>
         24        DO_ICALL                                         $15     
         25        SUB                                              ~16     $15, !0
         26        CONCAT                                           ~17     'create_function%3A+', ~16
         27        CONCAT                                           ~18     ~17, '%0A'
         28        ECHO                                                     ~18
   10    29        INIT_FCALL                                               'microtime'
         30        SEND_VAL                                                 <true>
         31        DO_ICALL                                         $19     
         32        ASSIGN                                                   !0, $19
   11    33        ASSIGN                                                   !2, 0
   12    34        ASSIGN                                                   !3, 0
         35      > JMP                                                      ->44
   13    36    >   ROPE_INIT                                     5  ~24     'return+log%28'
         37        ROPE_ADD                                      1  ~24     ~24, !3
         38        ROPE_ADD                                      2  ~24     ~24, '+%2A+'
         39        ROPE_ADD                                      3  ~24     ~24, !3
         40        ROPE_END                                      4  ~23     ~24, '%29%3B'
         41        INCLUDE_OR_EVAL                                  $27     ~23, EVAL
         42        ASSIGN_OP                                     1          !2, $27
   12    43        PRE_INC                                                  !3
         44    >   IS_SMALLER                                               !3, 1000
         45      > JMPNZ                                                    ~30, ->36
   14    46    >   INIT_FCALL                                               'microtime'
         47        SEND_VAL                                                 <true>
         48        DO_ICALL                                         $31     
         49        SUB                                              ~32     $31, !0
         50        CONCAT                                           ~33     'eval%3A+', ~32
         51        CONCAT                                           ~34     ~33, '%0A'
         52        ECHO                                                     ~34
   16    53        INIT_FCALL                                               'microtime'
         54        SEND_VAL                                                 <true>
         55        DO_ICALL                                         $35     
         56        ASSIGN                                                   !0, $35
   17    57        DECLARE_LAMBDA_FUNCTION                          ~37     [0]
         58        ASSIGN                                                   !1, ~37
   18    59        ASSIGN                                                   !2, 0
   19    60        ASSIGN                                                   !3, 0
         61      > JMP                                                      ->68
   20    62    >   INIT_DYNAMIC_CALL                                        !1
         63        SEND_VAR_EX                                              !3
         64        SEND_VAR_EX                                              !3
         65        DO_FCALL                                      0  $41     
         66        ASSIGN_OP                                     1          !2, $41
   19    67        PRE_INC                                                  !3
         68    >   IS_SMALLER                                               !3, 1000
         69      > JMPNZ                                                    ~44, ->62
   21    70    >   INIT_FCALL                                               'microtime'
         71        SEND_VAL                                                 <true>
         72        DO_ICALL                                         $45     
         73        SUB                                              ~46     $45, !0
         74        CONCAT                                           ~47     'arrow+function%3A+', ~46
         75        CONCAT                                           ~48     ~47, '%0A'
         76        ECHO                                                     ~48
   24    77        INIT_FCALL                                               'microtime'
         78        SEND_VAL                                                 <true>
         79        DO_ICALL                                         $49     
         80        ASSIGN                                                   !0, $49
   25    81        DECLARE_LAMBDA_FUNCTION                          ~51     [1]
         82        ASSIGN                                                   !1, ~51
   26    83        ASSIGN                                                   !2, 0
   27    84        ASSIGN                                                   !3, 0
         85      > JMP                                                      ->92
   28    86    >   INIT_DYNAMIC_CALL                                        !1
         87        SEND_VAR_EX                                              !3
         88        SEND_VAR_EX                                              !3
         89        DO_FCALL                                      0  $55     
         90        ASSIGN_OP                                     1          !2, $55
   27    91        PRE_INC                                                  !3
         92    >   IS_SMALLER                                               !3, 1000
         93      > JMPNZ                                                    ~58, ->86
   29    94    >   INIT_FCALL                                               'microtime'
         95        SEND_VAL                                                 <true>
         96        DO_ICALL                                         $59     
         97        SUB                                              ~60     $59, !0
         98        CONCAT                                           ~61     'anonymous+function%3A+', ~60
         99        CONCAT                                           ~62     ~61, '%0A'
        100        ECHO                                                     ~62
        101      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8euWR
function name:  {closure}
number of ops:  8
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        INIT_FCALL                                               'log'
          3        MUL                                              ~2      !0, !1
          4        SEND_VAL                                                 ~2
          5        DO_ICALL                                         $3      
          6      > RETURN                                                   $3
          7*     > RETURN                                                   null

End of Dynamic Function 0

Dynamic Function 1
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8euWR
function name:  {closure}
number of ops:  8
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        INIT_FCALL                                               'log'
          3        MUL                                              ~2      !0, !1
          4        SEND_VAL                                                 ~2
          5        DO_ICALL                                         $3      
          6      > RETURN                                                   $3
          7*     > RETURN                                                   null

End of Dynamic Function 1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
142.69 ms | 1440 KiB | 15 Q