3v4l.org

run code in 300+ PHP versions simultaneously
<?php function human_filesize($size,$unit="") { if( (!$unit && $size >= 1<<30) || $unit == "GB") return number_format($size/(1<<30),2)."GB"; if( (!$unit && $size >= 1<<20) || $unit == "MB") return number_format($size/(1<<20),2)."MB"; if( (!$unit && $size >= 1<<10) || $unit == "KB") return number_format($size/(1<<10),2)."KB"; return number_format($size)." bytes"; } $start = microtime(true); for($i=0;$i<10000;$i++) human_filesize(123456789); echo microtime(true) - $start . PHP_EOL;
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 = 6
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
2 jumps found. (Code = 44) Position 1 = 12, Position 2 = 6
Branch analysis from position: 12
Branch analysis from position: 6
filename:       /in/eUKPp
function name:  (null)
number of ops:  19
compiled vars:  !0 = $start, !1 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   INIT_FCALL                                               'microtime'
          1        SEND_VAL                                                 <true>
          2        DO_ICALL                                         $2      
          3        ASSIGN                                                   !0, $2
   14     4        ASSIGN                                                   !1, 0
          5      > JMP                                                      ->10
   15     6    >   INIT_FCALL                                               'human_filesize'
          7        SEND_VAL                                                 123456789
          8        DO_FCALL                                      0          
   14     9        PRE_INC                                                  !1
         10    >   IS_SMALLER                                               !1, 10000
         11      > JMPNZ                                                    ~7, ->6
   17    12    >   INIT_FCALL                                               'microtime'
         13        SEND_VAL                                                 <true>
         14        DO_ICALL                                         $8      
         15        SUB                                              ~9      $8, !0
         16        CONCAT                                           ~10     ~9, '%0A'
         17        ECHO                                                     ~10
         18      > RETURN                                                   1

Function human_filesize:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 4, Position 2 = 6
Branch analysis from position: 4
2 jumps found. (Code = 47) Position 1 = 7, Position 2 = 9
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 17
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
2 jumps found. (Code = 46) Position 1 = 19, Position 2 = 21
Branch analysis from position: 19
2 jumps found. (Code = 47) Position 1 = 22, Position 2 = 24
Branch analysis from position: 22
2 jumps found. (Code = 43) Position 1 = 25, Position 2 = 32
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 32
2 jumps found. (Code = 46) Position 1 = 34, Position 2 = 36
Branch analysis from position: 34
2 jumps found. (Code = 47) Position 1 = 37, Position 2 = 39
Branch analysis from position: 37
2 jumps found. (Code = 43) Position 1 = 40, Position 2 = 47
Branch analysis from position: 40
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 47
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 39
Branch analysis from position: 36
Branch analysis from position: 24
Branch analysis from position: 21
Branch analysis from position: 9
Branch analysis from position: 6
filename:       /in/eUKPp
function name:  human_filesize
number of ops:  53
compiled vars:  !0 = $size, !1 = $unit
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      ''
    4     2        BOOL_NOT                                         ~2      !1
          3      > JMPZ_EX                                          ~2      ~2, ->6
          4    >   IS_SMALLER_OR_EQUAL                              ~3      1073741824, !0
          5        BOOL                                             ~2      ~3
          6    > > JMPNZ_EX                                         ~2      ~2, ->9
          7    >   IS_EQUAL                                         ~4      !1, 'GB'
          8        BOOL                                             ~2      ~4
          9    > > JMPZ                                                     ~2, ->17
    5    10    >   INIT_FCALL                                               'number_format'
         11        DIV                                              ~5      !0, 1073741824
         12        SEND_VAL                                                 ~5
         13        SEND_VAL                                                 2
         14        DO_ICALL                                         $6      
         15        CONCAT                                           ~7      $6, 'GB'
         16      > RETURN                                                   ~7
    6    17    >   BOOL_NOT                                         ~8      !1
         18      > JMPZ_EX                                          ~8      ~8, ->21
         19    >   IS_SMALLER_OR_EQUAL                              ~9      1048576, !0
         20        BOOL                                             ~8      ~9
         21    > > JMPNZ_EX                                         ~8      ~8, ->24
         22    >   IS_EQUAL                                         ~10     !1, 'MB'
         23        BOOL                                             ~8      ~10
         24    > > JMPZ                                                     ~8, ->32
    7    25    >   INIT_FCALL                                               'number_format'
         26        DIV                                              ~11     !0, 1048576
         27        SEND_VAL                                                 ~11
         28        SEND_VAL                                                 2
         29        DO_ICALL                                         $12     
         30        CONCAT                                           ~13     $12, 'MB'
         31      > RETURN                                                   ~13
    8    32    >   BOOL_NOT                                         ~14     !1
         33      > JMPZ_EX                                          ~14     ~14, ->36
         34    >   IS_SMALLER_OR_EQUAL                              ~15     1024, !0
         35        BOOL                                             ~14     ~15
         36    > > JMPNZ_EX                                         ~14     ~14, ->39
         37    >   IS_EQUAL                                         ~16     !1, 'KB'
         38        BOOL                                             ~14     ~16
         39    > > JMPZ                                                     ~14, ->47
    9    40    >   INIT_FCALL                                               'number_format'
         41        DIV                                              ~17     !0, 1024
         42        SEND_VAL                                                 ~17
         43        SEND_VAL                                                 2
         44        DO_ICALL                                         $18     
         45        CONCAT                                           ~19     $18, 'KB'
         46      > RETURN                                                   ~19
   10    47    >   INIT_FCALL                                               'number_format'
         48        SEND_VAR                                                 !0
         49        DO_ICALL                                         $20     
         50        CONCAT                                           ~21     $20, '+bytes'
         51      > RETURN                                                   ~21
   11    52*     > RETURN                                                   null

End of function human_filesize

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
165.29 ms | 1022 KiB | 16 Q