3v4l.org

run code in 300+ PHP versions simultaneously
<?php $context = array('test' => array()); // optionally fill-in the test value with lots of data for ($i = 0; $i < 100000; $i++) { $context['test'][$i] = $i; } // you can also just create a big string // $context = str_repeat(' ', 1000000); // benchmark $time = microtime(true); for ($i = 0; $i < 100; $i++) { // the snippet of code to benchmark $tmp = isset($context['test']) ? $context['test'] : ''; } printf("TERNARY: %0.5d\n", (microtime(true) - $time)) . PHP_EOL; // benchmark $time = microtime(true); for ($i = 0; $i < 100; $i++) { // the snippet of code to benchmark $tmp = ''; if (isset($context['test'])) { $tmp = $context['test']; } } printf("IF : %0.5d\n", (microtime(true) - $time)); // benchmark $time = microtime(true); for ($i = 0; $i < 100; $i++) { // the snippet of code to benchmark if (isset($context['test'])) { $tmp = $context['test']; } else { $tmp = ''; } } printf("IF/ELSE: %0.5d\n", (microtime(true) - $time));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
2 jumps found. (Code = 44) Position 1 = 9, Position 2 = 3
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
2 jumps found. (Code = 44) Position 1 = 25, Position 2 = 15
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 47
Branch analysis from position: 47
2 jumps found. (Code = 44) Position 1 = 49, Position 2 = 41
Branch analysis from position: 49
1 jumps found. (Code = 42) Position 1 = 70
Branch analysis from position: 70
2 jumps found. (Code = 44) Position 1 = 72, Position 2 = 63
Branch analysis from position: 72
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 63
2 jumps found. (Code = 43) Position 1 = 65, Position 2 = 68
Branch analysis from position: 65
1 jumps found. (Code = 42) Position 1 = 69
Branch analysis from position: 69
2 jumps found. (Code = 44) Position 1 = 72, Position 2 = 63
Branch analysis from position: 72
Branch analysis from position: 63
Branch analysis from position: 68
2 jumps found. (Code = 44) Position 1 = 72, Position 2 = 63
Branch analysis from position: 72
Branch analysis from position: 63
Branch analysis from position: 41
2 jumps found. (Code = 43) Position 1 = 44, Position 2 = 46
Branch analysis from position: 44
2 jumps found. (Code = 44) Position 1 = 49, Position 2 = 41
Branch analysis from position: 49
Branch analysis from position: 41
Branch analysis from position: 46
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 20
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
2 jumps found. (Code = 44) Position 1 = 25, Position 2 = 15
Branch analysis from position: 25
Branch analysis from position: 15
Branch analysis from position: 20
2 jumps found. (Code = 44) Position 1 = 25, Position 2 = 15
Branch analysis from position: 25
Branch analysis from position: 15
Branch analysis from position: 3
2 jumps found. (Code = 44) Position 1 = 9, Position 2 = 3
Branch analysis from position: 9
Branch analysis from position: 3
filename:       /in/M45Ai
function name:  (null)
number of ops:  81
compiled vars:  !0 = $context, !1 = $i, !2 = $time, !3 = $tmp
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    6     1        ASSIGN                                                   !1, 0
          2      > JMP                                                      ->7
    7     3    >   FETCH_DIM_W                                      $6      !0, 'test'
          4        ASSIGN_DIM                                               $6, !1
          5        OP_DATA                                                  !1
    6     6        PRE_INC                                                  !1
          7    >   IS_SMALLER                                               !1, 100000
          8      > JMPNZ                                                    ~9, ->3
   13     9    >   INIT_FCALL                                               'microtime'
         10        SEND_VAL                                                 <true>
         11        DO_ICALL                                         $10     
         12        ASSIGN                                                   !2, $10
   14    13        ASSIGN                                                   !1, 0
         14      > JMP                                                      ->23
   16    15    >   ISSET_ISEMPTY_DIM_OBJ                         0          !0, 'test'
         16      > JMPZ                                                     ~13, ->20
         17    >   FETCH_DIM_R                                      ~14     !0, 'test'
         18        QM_ASSIGN                                        ~15     ~14
         19      > JMP                                                      ->21
         20    >   QM_ASSIGN                                        ~15     ''
         21    >   ASSIGN                                                   !3, ~15
   14    22        PRE_INC                                                  !1
         23    >   IS_SMALLER                                               !1, 100
         24      > JMPNZ                                                    ~18, ->15
   18    25    >   INIT_FCALL                                               'printf'
         26        SEND_VAL                                                 'TERNARY%3A+%250.5d%0A'
         27        INIT_FCALL                                               'microtime'
         28        SEND_VAL                                                 <true>
         29        DO_ICALL                                         $19     
         30        SUB                                              ~20     $19, !2
         31        SEND_VAL                                                 ~20
         32        DO_ICALL                                         $21     
         33        CONCAT                                           ~22     $21, '%0A'
         34        FREE                                                     ~22
   21    35        INIT_FCALL                                               'microtime'
         36        SEND_VAL                                                 <true>
         37        DO_ICALL                                         $23     
         38        ASSIGN                                                   !2, $23
   22    39        ASSIGN                                                   !1, 0
         40      > JMP                                                      ->47
   24    41    >   ASSIGN                                                   !3, ''
   25    42        ISSET_ISEMPTY_DIM_OBJ                         0          !0, 'test'
         43      > JMPZ                                                     ~27, ->46
   26    44    >   FETCH_DIM_R                                      ~28     !0, 'test'
         45        ASSIGN                                                   !3, ~28
   22    46    >   PRE_INC                                                  !1
         47    >   IS_SMALLER                                               !1, 100
         48      > JMPNZ                                                    ~31, ->41
   29    49    >   INIT_FCALL                                               'printf'
         50        SEND_VAL                                                 'IF+++++%3A+%250.5d%0A'
         51        INIT_FCALL                                               'microtime'
         52        SEND_VAL                                                 <true>
         53        DO_ICALL                                         $32     
         54        SUB                                              ~33     $32, !2
         55        SEND_VAL                                                 ~33
         56        DO_ICALL                                                 
   32    57        INIT_FCALL                                               'microtime'
         58        SEND_VAL                                                 <true>
         59        DO_ICALL                                         $35     
         60        ASSIGN                                                   !2, $35
   33    61        ASSIGN                                                   !1, 0
         62      > JMP                                                      ->70
   35    63    >   ISSET_ISEMPTY_DIM_OBJ                         0          !0, 'test'
         64      > JMPZ                                                     ~38, ->68
   36    65    >   FETCH_DIM_R                                      ~39     !0, 'test'
         66        ASSIGN                                                   !3, ~39
         67      > JMP                                                      ->69
   38    68    >   ASSIGN                                                   !3, ''
   33    69    >   PRE_INC                                                  !1
         70    >   IS_SMALLER                                               !1, 100
         71      > JMPNZ                                                    ~43, ->63
   41    72    >   INIT_FCALL                                               'printf'
         73        SEND_VAL                                                 'IF%2FELSE%3A+%250.5d%0A'
         74        INIT_FCALL                                               'microtime'
         75        SEND_VAL                                                 <true>
         76        DO_ICALL                                         $44     
         77        SUB                                              ~45     $44, !2
         78        SEND_VAL                                                 ~45
         79        DO_ICALL                                                 
         80      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.47 ms | 1404 KiB | 17 Q