3v4l.org

run code in 300+ PHP versions simultaneously
<?php function bytesToSize($bytes, $precision = 2) { $symbols = array('B', 'Kb', 'Mb', 'Gb', 'Tb', 'Pb', 'Eb', 'Zb', 'Yb'); $exp = (int)floor(log($bytes) / log(1024)); return sprintf('%.'. $precision .'f '. $symbols[$exp], $bytes / pow(1024, floor($exp))); } function mem() { return bytesToSize(memory_get_usage(true)); } function test($msg, $test) { $t = microtime(true); $test($msg); echo $msg .': <b>'. sprintf('%.6f', microtime(true) - $t) .'</b><br>'; } $array = range(0, 30000); foreach ($array as $v) { $b = $v; } foreach ($array as &$v) { $b = $v; } unset($v); $so = count($array); for ($i = 0; $i < $so; ++$i) { $b = $array[$i]; } while (list($k, $v) = each($array)) { $b =$v; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 9
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 9
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 9
2 jumps found. (Code = 125) Position 1 = 11, Position 2 = 14
Branch analysis from position: 11
2 jumps found. (Code = 126) Position 1 = 12, Position 2 = 14
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
2 jumps found. (Code = 44) Position 1 = 25, Position 2 = 20
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 27
Branch analysis from position: 27
2 jumps found. (Code = 44) Position 1 = 35, Position 2 = 26
Branch analysis from position: 35
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
2 jumps found. (Code = 44) Position 1 = 35, Position 2 = 26
Branch analysis from position: 35
Branch analysis from position: 26
Branch analysis from position: 20
2 jumps found. (Code = 44) Position 1 = 25, Position 2 = 20
Branch analysis from position: 25
Branch analysis from position: 20
Branch analysis from position: 14
Branch analysis from position: 9
filename:       /in/o3pZp
function name:  (null)
number of ops:  36
compiled vars:  !0 = $array, !1 = $v, !2 = $b, !3 = $so, !4 = $i, !5 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   INIT_FCALL                                               'range'
          1        SEND_VAL                                                 0
          2        SEND_VAL                                                 30000
          3        DO_ICALL                                         $6      
          4        ASSIGN                                                   !0, $6
   21     5      > FE_RESET_R                                       $8      !0, ->9
          6    > > FE_FETCH_R                                               $8, !1, ->9
   22     7    >   ASSIGN                                                   !2, !1
   21     8      > JMP                                                      ->6
          9    >   FE_FREE                                                  $8
   24    10      > FE_RESET_RW                                      $10     !0, ->14
         11    > > FE_FETCH_RW                                              $10, !1, ->14
   25    12    >   ASSIGN                                                   !2, !1
   24    13      > JMP                                                      ->11
         14    >   FE_FREE                                                  $10
   27    15        UNSET_CV                                                 !1
   28    16        COUNT                                            ~12     !0
         17        ASSIGN                                                   !3, ~12
   29    18        ASSIGN                                                   !4, 0
         19      > JMP                                                      ->23
   30    20    >   FETCH_DIM_R                                      ~15     !0, !4
         21        ASSIGN                                                   !2, ~15
   29    22        PRE_INC                                                  !4
         23    >   IS_SMALLER                                               !4, !3
         24      > JMPNZ                                                    ~18, ->20
   32    25    > > JMP                                                      ->27
   33    26    >   ASSIGN                                                   !2, !1
   32    27    >   INIT_FCALL_BY_NAME                                       'each'
         28        SEND_VAR_EX                                              !0
         29        DO_FCALL                                      0  $20     
         30        FETCH_LIST_R                                     $21     $20, 0
         31        ASSIGN                                                   !5, $21
         32        FETCH_LIST_R                                     $23     $20, 1
         33        ASSIGN                                                   !1, $23
         34      > JMPNZ                                                    $20, ->26
   34    35    > > RETURN                                                   1

Function bytestosize:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/o3pZp
function name:  bytesToSize
number of ops:  33
compiled vars:  !0 = $bytes, !1 = $precision, !2 = $symbols, !3 = $exp
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      2
    4     2        ASSIGN                                                   !2, <array>
    5     3        INIT_FCALL                                               'floor'
          4        INIT_FCALL                                               'log'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $5      
          7        INIT_FCALL                                               'log'
          8        SEND_VAL                                                 1024
          9        DO_ICALL                                         $6      
         10        DIV                                              ~7      $5, $6
         11        SEND_VAL                                                 ~7
         12        DO_ICALL                                         $8      
         13        CAST                                          4  ~9      $8
         14        ASSIGN                                                   !3, ~9
    6    15        INIT_FCALL                                               'sprintf'
         16        CONCAT                                           ~11     '%25.', !1
         17        CONCAT                                           ~12     ~11, 'f+'
         18        FETCH_DIM_R                                      ~13     !2, !3
         19        CONCAT                                           ~14     ~12, ~13
         20        SEND_VAL                                                 ~14
         21        INIT_FCALL                                               'pow'
         22        SEND_VAL                                                 1024
         23        INIT_FCALL                                               'floor'
         24        SEND_VAR                                                 !3
         25        DO_ICALL                                         $15     
         26        SEND_VAR                                                 $15
         27        DO_ICALL                                         $16     
         28        DIV                                              ~17     !0, $16
         29        SEND_VAL                                                 ~17
         30        DO_ICALL                                         $18     
         31      > RETURN                                                   $18
    7    32*     > RETURN                                                   null

End of function bytestosize

Function mem:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/o3pZp
function name:  mem
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   INIT_FCALL                                               'bytestosize'
          1        INIT_FCALL                                               'memory_get_usage'
          2        SEND_VAL                                                 <true>
          3        DO_ICALL                                         $0      
          4        SEND_VAR                                                 $0
          5        DO_FCALL                                      0  $1      
          6      > RETURN                                                   $1
   11     7*     > RETURN                                                   null

End of function mem

Function test:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/o3pZp
function name:  test
number of ops:  22
compiled vars:  !0 = $msg, !1 = $test, !2 = $t
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   14     2        INIT_FCALL                                               'microtime'
          3        SEND_VAL                                                 <true>
          4        DO_ICALL                                         $3      
          5        ASSIGN                                                   !2, $3
   15     6        INIT_DYNAMIC_CALL                                        !1
          7        SEND_VAR_EX                                              !0
          8        DO_FCALL                                      0          
   16     9        CONCAT                                           ~6      !0, '%3A+%3Cb%3E'
         10        INIT_FCALL                                               'sprintf'
         11        SEND_VAL                                                 '%25.6f'
         12        INIT_FCALL                                               'microtime'
         13        SEND_VAL                                                 <true>
         14        DO_ICALL                                         $7      
         15        SUB                                              ~8      $7, !2
         16        SEND_VAL                                                 ~8
         17        DO_ICALL                                         $9      
         18        CONCAT                                           ~10     ~6, $9
         19        CONCAT                                           ~11     ~10, '%3C%2Fb%3E%3Cbr%3E'
         20        ECHO                                                     ~11
   17    21      > RETURN                                                   null

End of function test

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.86 ms | 1407 KiB | 28 Q