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.2d\n", (microtime(true) - $time) * 1000) . 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.2d\n", (microtime(true) - $time) * 1000); // 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.2d\n", (microtime(true) - $time) * 1000);
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 = 48
Branch analysis from position: 48
2 jumps found. (Code = 44) Position 1 = 50, Position 2 = 42
Branch analysis from position: 50
1 jumps found. (Code = 42) Position 1 = 72
Branch analysis from position: 72
2 jumps found. (Code = 44) Position 1 = 74, Position 2 = 65
Branch analysis from position: 74
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 65
2 jumps found. (Code = 43) Position 1 = 67, Position 2 = 70
Branch analysis from position: 67
1 jumps found. (Code = 42) Position 1 = 71
Branch analysis from position: 71
2 jumps found. (Code = 44) Position 1 = 74, Position 2 = 65
Branch analysis from position: 74
Branch analysis from position: 65
Branch analysis from position: 70
2 jumps found. (Code = 44) Position 1 = 74, Position 2 = 65
Branch analysis from position: 74
Branch analysis from position: 65
Branch analysis from position: 42
2 jumps found. (Code = 43) Position 1 = 45, Position 2 = 47
Branch analysis from position: 45
2 jumps found. (Code = 44) Position 1 = 50, Position 2 = 42
Branch analysis from position: 50
Branch analysis from position: 42
Branch analysis from position: 47
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/2BuYM
function name:  (null)
number of ops:  84
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.2d%0A'
         27        INIT_FCALL                                               'microtime'
         28        SEND_VAL                                                 <true>
         29        DO_ICALL                                         $19     
         30        SUB                                              ~20     $19, !2
         31        MUL                                              ~21     ~20, 1000
         32        SEND_VAL                                                 ~21
         33        DO_ICALL                                         $22     
         34        CONCAT                                           ~23     $22, '%0A'
         35        FREE                                                     ~23
   21    36        INIT_FCALL                                               'microtime'
         37        SEND_VAL                                                 <true>
         38        DO_ICALL                                         $24     
         39        ASSIGN                                                   !2, $24
   22    40        ASSIGN                                                   !1, 0
         41      > JMP                                                      ->48
   24    42    >   ASSIGN                                                   !3, ''
   25    43        ISSET_ISEMPTY_DIM_OBJ                         0          !0, 'test'
         44      > JMPZ                                                     ~28, ->47
   26    45    >   FETCH_DIM_R                                      ~29     !0, 'test'
         46        ASSIGN                                                   !3, ~29
   22    47    >   PRE_INC                                                  !1
         48    >   IS_SMALLER                                               !1, 100
         49      > JMPNZ                                                    ~32, ->42
   29    50    >   INIT_FCALL                                               'printf'
         51        SEND_VAL                                                 'IF+++++%3A+%250.2d%0A'
         52        INIT_FCALL                                               'microtime'
         53        SEND_VAL                                                 <true>
         54        DO_ICALL                                         $33     
         55        SUB                                              ~34     $33, !2
         56        MUL                                              ~35     ~34, 1000
         57        SEND_VAL                                                 ~35
         58        DO_ICALL                                                 
   32    59        INIT_FCALL                                               'microtime'
         60        SEND_VAL                                                 <true>
         61        DO_ICALL                                         $37     
         62        ASSIGN                                                   !2, $37
   33    63        ASSIGN                                                   !1, 0
         64      > JMP                                                      ->72
   35    65    >   ISSET_ISEMPTY_DIM_OBJ                         0          !0, 'test'
         66      > JMPZ                                                     ~40, ->70
   36    67    >   FETCH_DIM_R                                      ~41     !0, 'test'
         68        ASSIGN                                                   !3, ~41
         69      > JMP                                                      ->71
   38    70    >   ASSIGN                                                   !3, ''
   33    71    >   PRE_INC                                                  !1
         72    >   IS_SMALLER                                               !1, 100
         73      > JMPNZ                                                    ~45, ->65
   41    74    >   INIT_FCALL                                               'printf'
         75        SEND_VAL                                                 'IF%2FELSE%3A+%250.2d%0A'
         76        INIT_FCALL                                               'microtime'
         77        SEND_VAL                                                 <true>
         78        DO_ICALL                                         $46     
         79        SUB                                              ~47     $46, !2
         80        MUL                                              ~48     ~47, 1000
         81        SEND_VAL                                                 ~48
         82        DO_ICALL                                                 
         83      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.28 ms | 1404 KiB | 17 Q