3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Benchmark example $string = '1234567890123456789012345678901234567890'; // Measure time for strict comparison $start = microtime(true); for ($i = 0; $i < 1000000; $i++) { if ('' === $string) { // Do something } } $end = microtime(true); $strictComparisonTime = $end - $start; // Measure time for count function $start = microtime(true); for ($i = 0; $i < 1000000; $i++) { if (\strlen($string)) { // Do something } } $end = microtime(true); $countFunctionTime = $end - $start; // Output the results echo "Time taken for strict comparison: " . $strictComparisonTime . " seconds\n"; echo "Time taken for strlen function: " . $countFunctionTime . " seconds\n";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
2 jumps found. (Code = 44) Position 1 = 12, Position 2 = 7
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 27
Branch analysis from position: 27
2 jumps found. (Code = 44) Position 1 = 29, Position 2 = 24
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
2 jumps found. (Code = 43) Position 1 = 26, Position 2 = 26
Branch analysis from position: 26
2 jumps found. (Code = 44) Position 1 = 29, Position 2 = 24
Branch analysis from position: 29
Branch analysis from position: 24
Branch analysis from position: 26
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 9
Branch analysis from position: 9
2 jumps found. (Code = 44) Position 1 = 12, Position 2 = 7
Branch analysis from position: 12
Branch analysis from position: 7
Branch analysis from position: 9
filename:       /in/tuB2q
function name:  (null)
number of ops:  42
compiled vars:  !0 = $string, !1 = $start, !2 = $i, !3 = $end, !4 = $strictComparisonTime, !5 = $countFunctionTime
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   ASSIGN                                                   !0, '1234567890123456789012345678901234567890'
    7     1        INIT_FCALL                                               'microtime'
          2        SEND_VAL                                                 <true>
          3        DO_ICALL                                         $7      
          4        ASSIGN                                                   !1, $7
    8     5        ASSIGN                                                   !2, 0
          6      > JMP                                                      ->10
    9     7    >   IS_IDENTICAL                                             !0, ''
          8      > JMPZ                                                     ~10, ->9
    8     9    >   PRE_INC                                                  !2
         10    >   IS_SMALLER                                               !2, 1000000
         11      > JMPNZ                                                    ~12, ->7
   13    12    >   INIT_FCALL                                               'microtime'
         13        SEND_VAL                                                 <true>
         14        DO_ICALL                                         $13     
         15        ASSIGN                                                   !3, $13
   14    16        SUB                                              ~15     !3, !1
         17        ASSIGN                                                   !4, ~15
   17    18        INIT_FCALL                                               'microtime'
         19        SEND_VAL                                                 <true>
         20        DO_ICALL                                         $17     
         21        ASSIGN                                                   !1, $17
   18    22        ASSIGN                                                   !2, 0
         23      > JMP                                                      ->27
   19    24    >   STRLEN                                           ~20     !0
         25      > JMPZ                                                     ~20, ->26
   18    26    >   PRE_INC                                                  !2
         27    >   IS_SMALLER                                               !2, 1000000
         28      > JMPNZ                                                    ~22, ->24
   23    29    >   INIT_FCALL                                               'microtime'
         30        SEND_VAL                                                 <true>
         31        DO_ICALL                                         $23     
         32        ASSIGN                                                   !3, $23
   24    33        SUB                                              ~25     !3, !1
         34        ASSIGN                                                   !5, ~25
   27    35        CONCAT                                           ~27     'Time+taken+for+strict+comparison%3A+', !4
         36        CONCAT                                           ~28     ~27, '+seconds%0A'
         37        ECHO                                                     ~28
   28    38        CONCAT                                           ~29     'Time+taken+for+strlen+function%3A+', !5
         39        CONCAT                                           ~30     ~29, '+seconds%0A'
         40        ECHO                                                     ~30
         41      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
137.9 ms | 1002 KiB | 14 Q