3v4l.org

run code in 300+ PHP versions simultaneously
<?php printf("test.php: php %s, phar-api %s\n", PHP_VERSION, PharData::apiVersion()); class Metrics { public $steps = array(); public function emit($what, $usage) { static $prev; static $beat = 0; if ($prev) { $this->steps[$beat] = $usage - $prev; } printf("[%s %05d] %s: %s\n", PHP_VERSION, ++$beat, $what, $prev ? sprintf('%d %+d', $usage, $usage - $prev): $usage); $prev = $usage; } public function tick($what) { $this->emit($what, memory_get_usage()); } public function summary() { $steps = $this->steps; $count = count($steps); $steps[] = null; for ($i = 1; $i < $count;) { $v = $steps[$i]; for ($j = $i + 1; $j <= $count; $j++) { $w = $steps[$j]; if ($w !== $v) { $c = $i === $j - 1 ? 1 : $j - $i; $cc[$v] = (isset($cc[$v]) ? $cc[$v] : 0) + $c; printf( "%-8s %-2s %+d %d\n", 1 === $c ? $i : sprintf('%d-%d', $i, $j - 1), 1 === $c ? '' : $j - $i, $v, $cc[$v] ); $i = $j; break; } } } } } $metrics = new Metrics(); $metrics->tick('start'); function phar_tick() { static $i = 0; $path = sprintf('%s/%d.tar', sys_get_temp_dir(), ++$i); $phar = new PharData($path); $phar->addEmptyDir('test'); unset($phar); unlink($path); } for ($i = 0; $i < 100; $i++) { phar_tick(); $metrics->tick('after'); } gc_collect_cycles(); $metrics->tick('end'); $metrics->summary();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
2 jumps found. (Code = 44) Position 1 = 23, Position 2 = 15
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
2 jumps found. (Code = 44) Position 1 = 23, Position 2 = 15
Branch analysis from position: 23
Branch analysis from position: 15
filename:       /in/lGa2n
function name:  (null)
number of ops:  31
compiled vars:  !0 = $metrics, !1 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'printf'
          1        SEND_VAL                                                 'test.php%3A+php+%25s%2C+phar-api+%25s%0A'
          2        SEND_VAL                                                 '8.0.0'
          3        INIT_STATIC_METHOD_CALL                                  'PharData', 'apiVersion'
          4        DO_FCALL                                      0  $2      
          5        SEND_VAR                                                 $2
          6        DO_ICALL                                                 
   49     7        NEW                                              $4      'Metrics'
          8        DO_FCALL                                      0          
          9        ASSIGN                                                   !0, $4
   51    10        INIT_METHOD_CALL                                         !0, 'tick'
         11        SEND_VAL_EX                                              'start'
         12        DO_FCALL                                      0          
   63    13        ASSIGN                                                   !1, 0
         14      > JMP                                                      ->21
   64    15    >   INIT_FCALL                                               'phar_tick'
         16        DO_FCALL                                      0          
   65    17        INIT_METHOD_CALL                                         !0, 'tick'
         18        SEND_VAL_EX                                              'after'
         19        DO_FCALL                                      0          
   63    20        PRE_INC                                                  !1
         21    >   IS_SMALLER                                               !1, 100
         22      > JMPNZ                                                    ~12, ->15
   67    23    >   INIT_FCALL                                               'gc_collect_cycles'
         24        DO_ICALL                                                 
   69    25        INIT_METHOD_CALL                                         !0, 'tick'
         26        SEND_VAL_EX                                              'end'
         27        DO_FCALL                                      0          
   70    28        INIT_METHOD_CALL                                         !0, 'summary'
         29        DO_FCALL                                      0          
         30      > RETURN                                                   1

Function phar_tick:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/lGa2n
function name:  phar_tick
number of ops:  22
compiled vars:  !0 = $i, !1 = $path, !2 = $phar
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   55     0  E >   BIND_STATIC                                              !0
   56     1        INIT_FCALL                                               'sprintf'
          2        SEND_VAL                                                 '%25s%2F%25d.tar'
          3        INIT_FCALL                                               'sys_get_temp_dir'
          4        DO_ICALL                                         $3      
          5        SEND_VAR                                                 $3
          6        PRE_INC                                          ~4      !0
          7        SEND_VAL                                                 ~4
          8        DO_ICALL                                         $5      
          9        ASSIGN                                                   !1, $5
   57    10        NEW                                              $7      'PharData'
         11        SEND_VAR_EX                                              !1
         12        DO_FCALL                                      0          
         13        ASSIGN                                                   !2, $7
   58    14        INIT_METHOD_CALL                                         !2, 'addEmptyDir'
         15        SEND_VAL_EX                                              'test'
         16        DO_FCALL                                      0          
   59    17        UNSET_CV                                                 !2
   60    18        INIT_FCALL                                               'unlink'
         19        SEND_VAR                                                 !1
         20        DO_ICALL                                                 
   61    21      > RETURN                                                   null

End of function phar_tick

Class Metrics:
Function emit:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 9
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 24
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
filename:       /in/lGa2n
function name:  emit
number of ops:  29
compiled vars:  !0 = $what, !1 = $usage, !2 = $prev, !3 = $beat
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   10     2        BIND_STATIC                                              !2
   11     3        BIND_STATIC                                              !3
   12     4      > JMPZ                                                     !2, ->9
   13     5    >   SUB                                              ~6      !1, !2
          6        FETCH_OBJ_W                                      $4      'steps'
          7        ASSIGN_DIM                                               $4, !3
          8        OP_DATA                                                  ~6
   15     9    >   INIT_FCALL                                               'printf'
         10        SEND_VAL                                                 '%5B%25s+%2505d%5D+%25s%3A+%25s%0A'
         11        SEND_VAL                                                 '8.0.0'
         12        PRE_INC                                          ~7      !3
         13        SEND_VAL                                                 ~7
         14        SEND_VAR                                                 !0
         15      > JMPZ                                                     !2, ->24
         16    >   INIT_FCALL                                               'sprintf'
         17        SEND_VAL                                                 '%25d+%25%2Bd'
         18        SEND_VAR                                                 !1
         19        SUB                                              ~8      !1, !2
         20        SEND_VAL                                                 ~8
         21        DO_ICALL                                         $9      
         22        QM_ASSIGN                                        ~10     $9
         23      > JMP                                                      ->25
         24    >   QM_ASSIGN                                        ~10     !1
         25    >   SEND_VAL                                                 ~10
         26        DO_ICALL                                                 
   16    27        ASSIGN                                                   !2, !1
   17    28      > RETURN                                                   null

End of function emit

Function tick:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/lGa2n
function name:  tick
number of ops:  8
compiled vars:  !0 = $what
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   RECV                                             !0      
   20     1        INIT_METHOD_CALL                                         'emit'
          2        SEND_VAR_EX                                              !0
          3        INIT_FCALL                                               'memory_get_usage'
          4        DO_ICALL                                         $1      
          5        SEND_VAR_NO_REF_EX                                       $1
          6        DO_FCALL                                      0          
   21     7      > RETURN                                                   null

End of function tick

Function summary:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 64
Branch analysis from position: 64
2 jumps found. (Code = 44) Position 1 = 66, Position 2 = 8
Branch analysis from position: 66
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 62
Branch analysis from position: 62
2 jumps found. (Code = 44) Position 1 = 64, Position 2 = 13
Branch analysis from position: 64
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 61
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 22
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
2 jumps found. (Code = 43) Position 1 = 27, Position 2 = 30
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
2 jumps found. (Code = 43) Position 1 = 38, Position 2 = 40
Branch analysis from position: 38
1 jumps found. (Code = 42) Position 1 = 47
Branch analysis from position: 47
2 jumps found. (Code = 43) Position 1 = 50, Position 2 = 52
Branch analysis from position: 50
1 jumps found. (Code = 42) Position 1 = 54
Branch analysis from position: 54
1 jumps found. (Code = 42) Position 1 = 64
Branch analysis from position: 64
Branch analysis from position: 52
1 jumps found. (Code = 42) Position 1 = 64
Branch analysis from position: 64
Branch analysis from position: 40
2 jumps found. (Code = 43) Position 1 = 50, Position 2 = 52
Branch analysis from position: 50
Branch analysis from position: 52
Branch analysis from position: 30
2 jumps found. (Code = 43) Position 1 = 38, Position 2 = 40
Branch analysis from position: 38
Branch analysis from position: 40
Branch analysis from position: 22
2 jumps found. (Code = 43) Position 1 = 27, Position 2 = 30
Branch analysis from position: 27
Branch analysis from position: 30
Branch analysis from position: 61
2 jumps found. (Code = 44) Position 1 = 64, Position 2 = 13
Branch analysis from position: 64
Branch analysis from position: 13
filename:       /in/lGa2n
function name:  summary
number of ops:  67
compiled vars:  !0 = $steps, !1 = $count, !2 = $i, !3 = $v, !4 = $j, !5 = $w, !6 = $c, !7 = $cc
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   FETCH_OBJ_R                                      ~8      'steps'
          1        ASSIGN                                                   !0, ~8
   25     2        COUNT                                            ~10     !0
          3        ASSIGN                                                   !1, ~10
   26     4        ASSIGN_DIM                                               !0
          5        OP_DATA                                                  null
   27     6        ASSIGN                                                   !2, 1
          7      > JMP                                                      ->64
   28     8    >   FETCH_DIM_R                                      ~14     !0, !2
          9        ASSIGN                                                   !3, ~14
   29    10        ADD                                              ~16     !2, 1
         11        ASSIGN                                                   !4, ~16
         12      > JMP                                                      ->62
   30    13    >   FETCH_DIM_R                                      ~18     !0, !4
         14        ASSIGN                                                   !5, ~18
   31    15        IS_NOT_IDENTICAL                                         !5, !3
         16      > JMPZ                                                     ~20, ->61
   32    17    >   SUB                                              ~21     !4, 1
         18        IS_IDENTICAL                                             !2, ~21
         19      > JMPZ                                                     ~22, ->22
         20    >   QM_ASSIGN                                        ~23     1
         21      > JMP                                                      ->24
         22    >   SUB                                              ~24     !4, !2
         23        QM_ASSIGN                                        ~23     ~24
         24    >   ASSIGN                                                   !6, ~23
   33    25        ISSET_ISEMPTY_DIM_OBJ                         0          !7, !3
         26      > JMPZ                                                     ~27, ->30
         27    >   FETCH_DIM_R                                      ~28     !7, !3
         28        QM_ASSIGN                                        ~29     ~28
         29      > JMP                                                      ->31
         30    >   QM_ASSIGN                                        ~29     0
         31    >   ADD                                              ~30     ~29, !6
         32        ASSIGN_DIM                                               !7, !3
         33        OP_DATA                                                  ~30
   34    34        INIT_FCALL                                               'printf'
   35    35        SEND_VAL                                                 '%25-8s+%25-2s+%25%2Bd+%25d%0A'
   36    36        IS_IDENTICAL                                             !6, 1
         37      > JMPZ                                                     ~31, ->40
         38    >   QM_ASSIGN                                        ~32     !2
         39      > JMP                                                      ->47
         40    >   INIT_FCALL                                               'sprintf'
         41        SEND_VAL                                                 '%25d-%25d'
         42        SEND_VAR                                                 !2
         43        SUB                                              ~33     !4, 1
         44        SEND_VAL                                                 ~33
         45        DO_ICALL                                         $34     
         46        QM_ASSIGN                                        ~32     $34
         47    >   SEND_VAL                                                 ~32
   37    48        IS_IDENTICAL                                             !6, 1
         49      > JMPZ                                                     ~35, ->52
         50    >   QM_ASSIGN                                        ~36     ''
         51      > JMP                                                      ->54
         52    >   SUB                                              ~37     !4, !2
         53        QM_ASSIGN                                        ~36     ~37
         54    >   SEND_VAL                                                 ~36
   38    55        SEND_VAR                                                 !3
   39    56        FETCH_DIM_R                                      ~38     !7, !3
         57        SEND_VAL                                                 ~38
         58        DO_ICALL                                                 
   41    59        ASSIGN                                                   !2, !4
   42    60      > JMP                                                      ->64
   29    61    >   PRE_INC                                                  !4
         62    >   IS_SMALLER_OR_EQUAL                                      !4, !1
         63      > JMPNZ                                                    ~42, ->13
   27    64    >   IS_SMALLER                                               !2, !1
         65      > JMPNZ                                                    ~43, ->8
   46    66    > > RETURN                                                   null

End of function summary

End of class Metrics.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.8 ms | 1415 KiB | 26 Q