3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ValueEncoder { public function encode($value) { $result = urlencode($value); return $result; } } class ValueDecoder { public function decode($value) { $result = urldecode($value); return $result; } } class RefEncoder { public function encode(&$value) { $value = urlencode($value); } } class RefDecoder { public function decode(&$value) { $value = urldecode($value); } } function genData() { return str_repeat('test', 5000000); } function valueTranscode() { $data = genData(); $encoder = new ValueEncoder(); $decoder = new ValueDecoder(); $data = $encoder->encode($data); $data = $decoder->decode($data); $data = strlen($data); } function refTranscode() { $data = genData(); $encoder = new RefEncoder(); $decoder = new RefDecoder(); $encoder->encode($data); $decoder->decode($data); $data = strlen($data); } $isRef = isset($argv[1]) && 'ref' === $argv[1]; echo ($isRef ? 'Ref: ' : 'Value: '); $s = microtime(true); for ($i = 0; $i < 10; ++$i) { if ($isRef) { refTranscode(); } else { valueTranscode(); } } $d = microtime(true) - $s; echo number_format($d, 2) . ' s, '; echo number_format(memory_get_peak_usage(true)/1000/1000,2) . ' MB'. PHP_EOL;
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 2, Position 2 = 5
Branch analysis from position: 2
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 9
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
2 jumps found. (Code = 44) Position 1 = 26, Position 2 = 17
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 21
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
2 jumps found. (Code = 44) Position 1 = 26, Position 2 = 17
Branch analysis from position: 26
Branch analysis from position: 17
Branch analysis from position: 21
2 jumps found. (Code = 44) Position 1 = 26, Position 2 = 17
Branch analysis from position: 26
Branch analysis from position: 17
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
Branch analysis from position: 5
filename:       /in/nV2S1
function name:  (null)
number of ops:  50
compiled vars:  !0 = $isRef, !1 = $argv, !2 = $s, !3 = $i, !4 = $d
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   60     0  E >   ISSET_ISEMPTY_DIM_OBJ                         0  ~5      !1, 1
          1      > JMPZ_EX                                          ~5      ~5, ->5
          2    >   FETCH_DIM_R                                      ~6      !1, 1
          3        IS_IDENTICAL                                     ~7      ~6, 'ref'
          4        BOOL                                             ~5      ~7
          5    >   ASSIGN                                                   !0, ~5
   62     6      > JMPZ                                                     !0, ->9
          7    >   QM_ASSIGN                                        ~9      'Ref%3A+'
          8      > JMP                                                      ->10
          9    >   QM_ASSIGN                                        ~9      'Value%3A+'
         10    >   ECHO                                                     ~9
   64    11        INIT_FCALL                                               'microtime'
         12        SEND_VAL                                                 <true>
         13        DO_ICALL                                         $10     
         14        ASSIGN                                                   !2, $10
   65    15        ASSIGN                                                   !3, 0
         16      > JMP                                                      ->24
   67    17    > > JMPZ                                                     !0, ->21
   69    18    >   INIT_FCALL                                               'reftranscode'
         19        DO_FCALL                                      0          
         20      > JMP                                                      ->23
   73    21    >   INIT_FCALL                                               'valuetranscode'
         22        DO_FCALL                                      0          
   65    23    >   PRE_INC                                                  !3
         24    >   IS_SMALLER                                               !3, 10
         25      > JMPNZ                                                    ~16, ->17
   76    26    >   INIT_FCALL                                               'microtime'
         27        SEND_VAL                                                 <true>
         28        DO_ICALL                                         $17     
         29        SUB                                              ~18     $17, !2
         30        ASSIGN                                                   !4, ~18
   78    31        INIT_FCALL                                               'number_format'
         32        SEND_VAR                                                 !4
         33        SEND_VAL                                                 2
         34        DO_ICALL                                         $20     
         35        CONCAT                                           ~21     $20, '+s%2C+'
         36        ECHO                                                     ~21
   79    37        INIT_FCALL                                               'number_format'
         38        INIT_FCALL                                               'memory_get_peak_usage'
         39        SEND_VAL                                                 <true>
         40        DO_ICALL                                         $22     
         41        DIV                                              ~23     $22, 1000
         42        DIV                                              ~24     ~23, 1000
         43        SEND_VAL                                                 ~24
         44        SEND_VAL                                                 2
         45        DO_ICALL                                         $25     
         46        CONCAT                                           ~26     $25, '+MB'
         47        CONCAT                                           ~27     ~26, '%0A'
         48        ECHO                                                     ~27
         49      > RETURN                                                   1

Function gendata:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nV2S1
function name:  genData
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   39     0  E >   INIT_FCALL                                               'str_repeat'
          1        SEND_VAL                                                 'test'
          2        SEND_VAL                                                 5000000
          3        DO_ICALL                                         $0      
          4      > RETURN                                                   $0
   40     5*     > RETURN                                                   null

End of function gendata

Function valuetranscode:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nV2S1
function name:  valueTranscode
number of ops:  20
compiled vars:  !0 = $data, !1 = $encoder, !2 = $decoder
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   43     0  E >   INIT_FCALL                                               'gendata'
          1        DO_FCALL                                      0  $3      
          2        ASSIGN                                                   !0, $3
   44     3        NEW                                              $5      'ValueEncoder'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !1, $5
   45     6        NEW                                              $8      'ValueDecoder'
          7        DO_FCALL                                      0          
          8        ASSIGN                                                   !2, $8
   46     9        INIT_METHOD_CALL                                         !1, 'encode'
         10        SEND_VAR_EX                                              !0
         11        DO_FCALL                                      0  $11     
         12        ASSIGN                                                   !0, $11
   47    13        INIT_METHOD_CALL                                         !2, 'decode'
         14        SEND_VAR_EX                                              !0
         15        DO_FCALL                                      0  $13     
         16        ASSIGN                                                   !0, $13
   48    17        STRLEN                                           ~15     !0
         18        ASSIGN                                                   !0, ~15
   49    19      > RETURN                                                   null

End of function valuetranscode

Function reftranscode:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nV2S1
function name:  refTranscode
number of ops:  18
compiled vars:  !0 = $data, !1 = $encoder, !2 = $decoder
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   52     0  E >   INIT_FCALL                                               'gendata'
          1        DO_FCALL                                      0  $3      
          2        ASSIGN                                                   !0, $3
   53     3        NEW                                              $5      'RefEncoder'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !1, $5
   54     6        NEW                                              $8      'RefDecoder'
          7        DO_FCALL                                      0          
          8        ASSIGN                                                   !2, $8
   55     9        INIT_METHOD_CALL                                         !1, 'encode'
         10        SEND_VAR_EX                                              !0
         11        DO_FCALL                                      0          
   56    12        INIT_METHOD_CALL                                         !2, 'decode'
         13        SEND_VAR_EX                                              !0
         14        DO_FCALL                                      0          
   57    15        STRLEN                                           ~13     !0
         16        ASSIGN                                                   !0, ~13
   58    17      > RETURN                                                   null

End of function reftranscode

Class ValueEncoder:
Function encode:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nV2S1
function name:  encode
number of ops:  7
compiled vars:  !0 = $value, !1 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
    7     1        INIT_FCALL                                               'urlencode'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $2      
          4        ASSIGN                                                   !1, $2
    8     5      > RETURN                                                   !1
    9     6*     > RETURN                                                   null

End of function encode

End of class ValueEncoder.

Class ValueDecoder:
Function decode:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nV2S1
function name:  decode
number of ops:  7
compiled vars:  !0 = $value, !1 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
   16     1        INIT_FCALL                                               'urldecode'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $2      
          4        ASSIGN                                                   !1, $2
   17     5      > RETURN                                                   !1
   18     6*     > RETURN                                                   null

End of function decode

End of class ValueDecoder.

Class RefEncoder:
Function encode:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nV2S1
function name:  encode
number of ops:  6
compiled vars:  !0 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   RECV                                             !0      
   25     1        INIT_FCALL                                               'urlencode'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $1      
          4        ASSIGN                                                   !0, $1
   26     5      > RETURN                                                   null

End of function encode

End of class RefEncoder.

Class RefDecoder:
Function decode:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nV2S1
function name:  decode
number of ops:  6
compiled vars:  !0 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   31     0  E >   RECV                                             !0      
   33     1        INIT_FCALL                                               'urldecode'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $1      
          4        ASSIGN                                                   !0, $1
   34     5      > RETURN                                                   null

End of function decode

End of class RefDecoder.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.44 ms | 1402 KiB | 29 Q