3v4l.org

run code in 300+ PHP versions simultaneously
<?php function acceptOne($a) {}; final class Foo { public $notTyped; public int $typed; } $benchFx = function (string $msg, \Closure $fx) { $times = []; for ($i = 0; $i < 10; $i++) { $t = microtime(true); $fx(); $t = microtime(true) - $t; $times[] = $t; } $bestTime = min($times); echo $msg . ': ' . round($bestTime * 1000, 2) . " ms\n"; }; $benchFx('assign not typed', function () { $foo = new Foo(); for ($i = 0; $i < 100_000; $i++) { $foo->notTyped = $i; $foo->notTyped = $i; $foo->notTyped = $i; $foo->notTyped = $i; $foo->notTyped = $i; } acceptOne($foo); }); $benchFx('assign typed', function () { $foo = new Foo(); for ($i = 0; $i < 100_000; $i++) { $foo->typed = $i; $foo->typed = $i; $foo->typed = $i; $foo->typed = $i; $foo->typed = $i; } acceptOne($foo); });
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/FGeEf
function name:  (null)
number of ops:  13
compiled vars:  !0 = $benchFx
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   DECLARE_LAMBDA_FUNCTION                          ~1      [0]
          1        ASSIGN                                                   !0, ~1
   24     2        INIT_DYNAMIC_CALL                                        !0
          3        SEND_VAL_EX                                              'assign+not+typed'
          4        DECLARE_LAMBDA_FUNCTION                          ~3      [1]
   34     5        SEND_VAL_EX                                              ~3
   24     6        DO_FCALL                                      0          
   36     7        INIT_DYNAMIC_CALL                                        !0
          8        SEND_VAL_EX                                              'assign+typed'
          9        DECLARE_LAMBDA_FUNCTION                          ~5      [2]
   46    10        SEND_VAL_EX                                              ~5
   36    11        DO_FCALL                                      0          
   46    12      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
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/FGeEf
function name:  {closure}
number of ops:  35
compiled vars:  !0 = $msg, !1 = $fx, !2 = $times, !3 = $i, !4 = $t, !5 = $bestTime
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   12     2        ASSIGN                                                   !2, <array>
   13     3        ASSIGN                                                   !3, 0
          4      > JMP                                                      ->19
   14     5    >   INIT_FCALL                                               'microtime'
          6        SEND_VAL                                                 <true>
          7        DO_ICALL                                         $8      
          8        ASSIGN                                                   !4, $8
   15     9        INIT_DYNAMIC_CALL                                        !1
         10        DO_FCALL                                      0          
   16    11        INIT_FCALL                                               'microtime'
         12        SEND_VAL                                                 <true>
         13        DO_ICALL                                         $11     
         14        SUB                                              ~12     $11, !4
         15        ASSIGN                                                   !4, ~12
   17    16        ASSIGN_DIM                                               !2
         17        OP_DATA                                                  !4
   13    18        PRE_INC                                                  !3
         19    >   IS_SMALLER                                               !3, 10
         20      > JMPNZ                                                    ~16, ->5
   20    21    >   INIT_FCALL                                               'min'
         22        SEND_VAR                                                 !2
         23        DO_ICALL                                         $17     
         24        ASSIGN                                                   !5, $17
   21    25        CONCAT                                           ~19     !0, '%3A+'
         26        INIT_FCALL                                               'round'
         27        MUL                                              ~20     !5, 1000
         28        SEND_VAL                                                 ~20
         29        SEND_VAL                                                 2
         30        DO_ICALL                                         $21     
         31        CONCAT                                           ~22     ~19, $21
         32        CONCAT                                           ~23     ~22, '+ms%0A'
         33        ECHO                                                     ~23
   22    34      > RETURN                                                   null

End of Dynamic Function 0

Dynamic Function 1
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
2 jumps found. (Code = 44) Position 1 = 18, Position 2 = 5
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
2 jumps found. (Code = 44) Position 1 = 18, Position 2 = 5
Branch analysis from position: 18
Branch analysis from position: 5
filename:       /in/FGeEf
function name:  {closure}
number of ops:  22
compiled vars:  !0 = $foo, !1 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   NEW                                              $2      'Foo'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $2
   26     3        ASSIGN                                                   !1, 0
          4      > JMP                                                      ->16
   27     5    >   ASSIGN_OBJ                                               !0, 'notTyped'
          6        OP_DATA                                                  !1
   28     7        ASSIGN_OBJ                                               !0, 'notTyped'
          8        OP_DATA                                                  !1
   29     9        ASSIGN_OBJ                                               !0, 'notTyped'
         10        OP_DATA                                                  !1
   30    11        ASSIGN_OBJ                                               !0, 'notTyped'
         12        OP_DATA                                                  !1
   31    13        ASSIGN_OBJ                                               !0, 'notTyped'
         14        OP_DATA                                                  !1
   26    15        PRE_INC                                                  !1
         16    >   IS_SMALLER                                               !1, 100000
         17      > JMPNZ                                                    ~12, ->5
   33    18    >   INIT_FCALL                                               'acceptone'
         19        SEND_VAR                                                 !0
         20        DO_FCALL                                      0          
   34    21      > RETURN                                                   null

End of Dynamic Function 1

Dynamic Function 2
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
2 jumps found. (Code = 44) Position 1 = 18, Position 2 = 5
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
2 jumps found. (Code = 44) Position 1 = 18, Position 2 = 5
Branch analysis from position: 18
Branch analysis from position: 5
filename:       /in/FGeEf
function name:  {closure}
number of ops:  22
compiled vars:  !0 = $foo, !1 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   37     0  E >   NEW                                              $2      'Foo'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $2
   38     3        ASSIGN                                                   !1, 0
          4      > JMP                                                      ->16
   39     5    >   ASSIGN_OBJ                                               !0, 'typed'
          6        OP_DATA                                                  !1
   40     7        ASSIGN_OBJ                                               !0, 'typed'
          8        OP_DATA                                                  !1
   41     9        ASSIGN_OBJ                                               !0, 'typed'
         10        OP_DATA                                                  !1
   42    11        ASSIGN_OBJ                                               !0, 'typed'
         12        OP_DATA                                                  !1
   43    13        ASSIGN_OBJ                                               !0, 'typed'
         14        OP_DATA                                                  !1
   38    15        PRE_INC                                                  !1
         16    >   IS_SMALLER                                               !1, 100000
         17      > JMPNZ                                                    ~12, ->5
   45    18    >   INIT_FCALL                                               'acceptone'
         19        SEND_VAR                                                 !0
         20        DO_FCALL                                      0          
   46    21      > RETURN                                                   null

End of Dynamic Function 2

Function acceptone:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/FGeEf
function name:  acceptOne
number of ops:  2
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1      > RETURN                                                   null

End of function acceptone

Class Foo: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.87 ms | 1015 KiB | 18 Q