3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Simple: $start = microtime(true); for($i = 0; $i < 10000000; $i++) { $a = 1 + 2; } echo 'Simple: ' . microtime(true) - $start; // Separate function: $start = microtime(true); function add() { return 1 + 2; } for($i = 0; $i < 10000000; $i++) { $a = add(); } echo "\n\nSeparate function: " . microtime(true) - $start; // Wrapped in {...} $start = microtime(true); for($i = 0; $i < 10000000; $i++) { { $a = 1 + 2; } } echo "\n\nWrapped in {...}: " . microtime(true) - $start; // IIFE $start = microtime(true); for($i = 0; $i < 10000000; $i++) { $a = (function() { return 1 + 2; })(); } echo "\n\nWrapped in IIFE: " . microtime(true) - $start;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
2 jumps found. (Code = 44) Position 1 = 10, Position 2 = 6
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
2 jumps found. (Code = 44) Position 1 = 28, Position 2 = 22
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 42
Branch analysis from position: 42
2 jumps found. (Code = 44) Position 1 = 44, Position 2 = 40
Branch analysis from position: 44
1 jumps found. (Code = 42) Position 1 = 61
Branch analysis from position: 61
2 jumps found. (Code = 44) Position 1 = 63, Position 2 = 56
Branch analysis from position: 63
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 56
2 jumps found. (Code = 44) Position 1 = 63, Position 2 = 56
Branch analysis from position: 63
Branch analysis from position: 56
Branch analysis from position: 40
2 jumps found. (Code = 44) Position 1 = 44, Position 2 = 40
Branch analysis from position: 44
Branch analysis from position: 40
Branch analysis from position: 22
2 jumps found. (Code = 44) Position 1 = 28, Position 2 = 22
Branch analysis from position: 28
Branch analysis from position: 22
Branch analysis from position: 6
2 jumps found. (Code = 44) Position 1 = 10, Position 2 = 6
Branch analysis from position: 10
Branch analysis from position: 6
filename:       /in/ZWZfZ
function name:  (null)
number of ops:  70
compiled vars:  !0 = $start, !1 = $i, !2 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   INIT_FCALL                                               'microtime'
          1        SEND_VAL                                                 <true>
          2        DO_ICALL                                         $3      
          3        ASSIGN                                                   !0, $3
    7     4        ASSIGN                                                   !1, 0
          5      > JMP                                                      ->8
    8     6    >   ASSIGN                                                   !2, 3
    7     7        PRE_INC                                                  !1
          8    >   IS_SMALLER                                               !1, 10000000
          9      > JMPNZ                                                    ~8, ->6
   11    10    >   INIT_FCALL                                               'microtime'
         11        SEND_VAL                                                 <true>
         12        DO_ICALL                                         $9      
         13        SUB                                              ~10     $9, !0
         14        CONCAT                                           ~11     'Simple%3A+', ~10
         15        ECHO                                                     ~11
   17    16        INIT_FCALL                                               'microtime'
         17        SEND_VAL                                                 <true>
         18        DO_ICALL                                         $12     
         19        ASSIGN                                                   !0, $12
   24    20        ASSIGN                                                   !1, 0
         21      > JMP                                                      ->26
   25    22    >   INIT_FCALL                                               'add'
         23        DO_FCALL                                      0  $15     
         24        ASSIGN                                                   !2, $15
   24    25        PRE_INC                                                  !1
         26    >   IS_SMALLER                                               !1, 10000000
         27      > JMPNZ                                                    ~18, ->22
   28    28    >   INIT_FCALL                                               'microtime'
         29        SEND_VAL                                                 <true>
         30        DO_ICALL                                         $19     
         31        SUB                                              ~20     $19, !0
         32        CONCAT                                           ~21     '%0A%0ASeparate+function%3A+', ~20
         33        ECHO                                                     ~21
   34    34        INIT_FCALL                                               'microtime'
         35        SEND_VAL                                                 <true>
         36        DO_ICALL                                         $22     
         37        ASSIGN                                                   !0, $22
   36    38        ASSIGN                                                   !1, 0
         39      > JMP                                                      ->42
   38    40    >   ASSIGN                                                   !2, 3
   36    41        PRE_INC                                                  !1
         42    >   IS_SMALLER                                               !1, 10000000
         43      > JMPNZ                                                    ~27, ->40
   42    44    >   INIT_FCALL                                               'microtime'
         45        SEND_VAL                                                 <true>
         46        DO_ICALL                                         $28     
         47        SUB                                              ~29     $28, !0
         48        CONCAT                                           ~30     '%0A%0AWrapped+in+%7B...%7D%3A+', ~29
         49        ECHO                                                     ~30
   48    50        INIT_FCALL                                               'microtime'
         51        SEND_VAL                                                 <true>
         52        DO_ICALL                                         $31     
         53        ASSIGN                                                   !0, $31
   50    54        ASSIGN                                                   !1, 0
         55      > JMP                                                      ->61
   51    56    >   DECLARE_LAMBDA_FUNCTION                          ~34     [0]
   53    57        INIT_DYNAMIC_CALL                                        ~34
         58        DO_FCALL                                      0  $35     
   51    59        ASSIGN                                                   !2, $35
   50    60        PRE_INC                                                  !1
         61    >   IS_SMALLER                                               !1, 10000000
         62      > JMPNZ                                                    ~38, ->56
   56    63    >   INIT_FCALL                                               'microtime'
         64        SEND_VAL                                                 <true>
         65        DO_ICALL                                         $39     
         66        SUB                                              ~40     $39, !0
         67        CONCAT                                           ~41     '%0A%0AWrapped+in+IIFE%3A+', ~40
         68        ECHO                                                     ~41
   57    69      > 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/ZWZfZ
function name:  {closure}
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   52     0  E > > RETURN                                                   3
   53     1*     > RETURN                                                   null

End of Dynamic Function 0

Function add:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZWZfZ
function name:  add
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E > > RETURN                                                   3
   22     1*     > RETURN                                                   null

End of function add

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
147.31 ms | 1021 KiB | 15 Q