3v4l.org

run code in 300+ PHP versions simultaneously
<?php $foo = true; $start = microtime(true); for ($i = 1; $i < 1000000; $i++) { $bar = $foo ? 1 : 2; } $ternary = microtime(true) - $start; $start = microtime(true); for ($i = 1; $i < 1000000; $i++) { if ($foo) { $bar = 1; } else { $bar = 2; } } $ifelse = microtime(true) - $start; print "The winner is: " . ($ternary > $ifelse ? 'if/else' : 'ternary');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
2 jumps found. (Code = 44) Position 1 = 15, Position 2 = 7
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
2 jumps found. (Code = 44) Position 1 = 33, Position 2 = 26
Branch analysis from position: 33
2 jumps found. (Code = 43) Position 1 = 40, Position 2 = 42
Branch analysis from position: 40
1 jumps found. (Code = 42) Position 1 = 43
Branch analysis from position: 43
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 42
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
2 jumps found. (Code = 43) Position 1 = 27, Position 2 = 29
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
2 jumps found. (Code = 44) Position 1 = 33, Position 2 = 26
Branch analysis from position: 33
Branch analysis from position: 26
Branch analysis from position: 29
2 jumps found. (Code = 44) Position 1 = 33, Position 2 = 26
Branch analysis from position: 33
Branch analysis from position: 26
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 10
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
2 jumps found. (Code = 44) Position 1 = 15, Position 2 = 7
Branch analysis from position: 15
Branch analysis from position: 7
Branch analysis from position: 10
2 jumps found. (Code = 44) Position 1 = 15, Position 2 = 7
Branch analysis from position: 15
Branch analysis from position: 7
filename:       /in/Jnps1
function name:  (null)
number of ops:  46
compiled vars:  !0 = $foo, !1 = $start, !2 = $i, !3 = $bar, !4 = $ternary, !5 = $ifelse
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <true>
    5     1        INIT_FCALL                                               'microtime'
          2        SEND_VAL                                                 <true>
          3        DO_ICALL                                         $7      
          4        ASSIGN                                                   !1, $7
    6     5        ASSIGN                                                   !2, 1
          6      > JMP                                                      ->13
    7     7    > > JMPZ                                                     !0, ->10
          8    >   QM_ASSIGN                                        ~10     1
          9      > JMP                                                      ->11
         10    >   QM_ASSIGN                                        ~10     2
         11    >   ASSIGN                                                   !3, ~10
    6    12        PRE_INC                                                  !2
         13    >   IS_SMALLER                                               !2, 1000000
         14      > JMPNZ                                                    ~13, ->7
    9    15    >   INIT_FCALL                                               'microtime'
         16        SEND_VAL                                                 <true>
         17        DO_ICALL                                         $14     
         18        SUB                                              ~15     $14, !1
         19        ASSIGN                                                   !4, ~15
   11    20        INIT_FCALL                                               'microtime'
         21        SEND_VAL                                                 <true>
         22        DO_ICALL                                         $17     
         23        ASSIGN                                                   !1, $17
   12    24        ASSIGN                                                   !2, 1
         25      > JMP                                                      ->31
   13    26    > > JMPZ                                                     !0, ->29
   14    27    >   ASSIGN                                                   !3, 1
         28      > JMP                                                      ->30
   17    29    >   ASSIGN                                                   !3, 2
   12    30    >   PRE_INC                                                  !2
         31    >   IS_SMALLER                                               !2, 1000000
         32      > JMPNZ                                                    ~23, ->26
   20    33    >   INIT_FCALL                                               'microtime'
         34        SEND_VAL                                                 <true>
         35        DO_ICALL                                         $24     
         36        SUB                                              ~25     $24, !1
         37        ASSIGN                                                   !5, ~25
   22    38        IS_SMALLER                                               !5, !4
         39      > JMPZ                                                     ~27, ->42
         40    >   QM_ASSIGN                                        ~28     'if%2Felse'
         41      > JMP                                                      ->43
         42    >   QM_ASSIGN                                        ~28     'ternary'
         43    >   CONCAT                                           ~29     'The+winner+is%3A+', ~28
         44        ECHO                                                     ~29
         45      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
160.56 ms | 1404 KiB | 15 Q