3v4l.org

run code in 300+ PHP versions simultaneously
<?php $attempts = 100000; $test = 1; if (true || $test == 1) { $start = microtime(true); for ($i = 0; $i < $attempts; $i++) { $user = array( 'id' => 27, 'name' => 'Pepe' ); } $end = microtime(true); echo 'Array: ' . ($end - $start) . " <br />\n"; } if (true || $test == 2) { $start = microtime(true); for ($i = 0; $i < $attempts; $i++) { $user = new stdClass(); $user->id = 27; $user->name = 'Pepe'; } $end = microtime(true); echo 'Object: ' . ($end - $start) . " <br />\n"; } if (true || $test == 3) { $start = microtime(true); for ($i = 0; $i < $attempts; $i++) { $user = (object) array( 'id' => 27, 'name' => 'Pepe' ); } $end = microtime(true); echo 'Cast: ' . ($end - $start) . " <br />\n"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 21
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
2 jumps found. (Code = 44) Position 1 = 13, Position 2 = 9
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 46
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 36
Branch analysis from position: 36
2 jumps found. (Code = 44) Position 1 = 38, Position 2 = 28
Branch analysis from position: 38
2 jumps found. (Code = 43) Position 1 = 47, Position 2 = 66
Branch analysis from position: 47
1 jumps found. (Code = 42) Position 1 = 56
Branch analysis from position: 56
2 jumps found. (Code = 44) Position 1 = 58, Position 2 = 53
Branch analysis from position: 58
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 53
2 jumps found. (Code = 44) Position 1 = 58, Position 2 = 53
Branch analysis from position: 58
Branch analysis from position: 53
Branch analysis from position: 66
Branch analysis from position: 28
2 jumps found. (Code = 44) Position 1 = 38, Position 2 = 28
Branch analysis from position: 38
Branch analysis from position: 28
Branch analysis from position: 46
Branch analysis from position: 9
2 jumps found. (Code = 44) Position 1 = 13, Position 2 = 9
Branch analysis from position: 13
Branch analysis from position: 9
Branch analysis from position: 21
filename:       /in/8IeU3
function name:  (null)
number of ops:  67
compiled vars:  !0 = $attempts, !1 = $test, !2 = $start, !3 = $i, !4 = $user, !5 = $end
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 100000
    4     1        ASSIGN                                                   !1, 1
    6     2      > JMPZ                                                     <true>, ->21
    7     3    >   INIT_FCALL                                               'microtime'
          4        SEND_VAL                                                 <true>
          5        DO_ICALL                                         $8      
          6        ASSIGN                                                   !2, $8
    8     7        ASSIGN                                                   !3, 0
          8      > JMP                                                      ->11
    9     9    >   ASSIGN                                                   !4, <array>
    8    10        PRE_INC                                                  !3
         11    >   IS_SMALLER                                               !3, !0
         12      > JMPNZ                                                    ~13, ->9
   15    13    >   INIT_FCALL                                               'microtime'
         14        SEND_VAL                                                 <true>
         15        DO_ICALL                                         $14     
         16        ASSIGN                                                   !5, $14
   16    17        SUB                                              ~16     !5, !2
         18        CONCAT                                           ~17     'Array%3A+', ~16
         19        CONCAT                                           ~18     ~17, '+%3Cbr+%2F%3E%0A'
         20        ECHO                                                     ~18
   19    21    > > JMPZ                                                     <true>, ->46
   20    22    >   INIT_FCALL                                               'microtime'
         23        SEND_VAL                                                 <true>
         24        DO_ICALL                                         $19     
         25        ASSIGN                                                   !2, $19
   21    26        ASSIGN                                                   !3, 0
         27      > JMP                                                      ->36
   22    28    >   NEW                                              $22     'stdClass'
         29        DO_FCALL                                      0          
         30        ASSIGN                                                   !4, $22
   23    31        ASSIGN_OBJ                                               !4, 'id'
         32        OP_DATA                                                  27
   24    33        ASSIGN_OBJ                                               !4, 'name'
         34        OP_DATA                                                  'Pepe'
   21    35        PRE_INC                                                  !3
         36    >   IS_SMALLER                                               !3, !0
         37      > JMPNZ                                                    ~28, ->28
   26    38    >   INIT_FCALL                                               'microtime'
         39        SEND_VAL                                                 <true>
         40        DO_ICALL                                         $29     
         41        ASSIGN                                                   !5, $29
   27    42        SUB                                              ~31     !5, !2
         43        CONCAT                                           ~32     'Object%3A+', ~31
         44        CONCAT                                           ~33     ~32, '+%3Cbr+%2F%3E%0A'
         45        ECHO                                                     ~33
   30    46    > > JMPZ                                                     <true>, ->66
   31    47    >   INIT_FCALL                                               'microtime'
         48        SEND_VAL                                                 <true>
         49        DO_ICALL                                         $34     
         50        ASSIGN                                                   !2, $34
   32    51        ASSIGN                                                   !3, 0
         52      > JMP                                                      ->56
   34    53    >   CAST                                          8  ~37     <array>
   33    54        ASSIGN                                                   !4, ~37
   32    55        PRE_INC                                                  !3
         56    >   IS_SMALLER                                               !3, !0
         57      > JMPNZ                                                    ~40, ->53
   38    58    >   INIT_FCALL                                               'microtime'
         59        SEND_VAL                                                 <true>
         60        DO_ICALL                                         $41     
         61        ASSIGN                                                   !5, $41
   39    62        SUB                                              ~43     !5, !2
         63        CONCAT                                           ~44     'Cast%3A+', ~43
         64        CONCAT                                           ~45     ~44, '+%3Cbr+%2F%3E%0A'
         65        ECHO                                                     ~45
   40    66    > > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
140.14 ms | 1400 KiB | 15 Q