3v4l.org

run code in 300+ PHP versions simultaneously
<?php function probe($label, $times, $callback) { $mem = memory_get_usage(); $start = microtime(true); $array = $callback($times); $time = microtime(true) - $start; $mem = sprintf('%.3f', (memory_get_usage() - $mem) / 1024 / 1024); return "$label: $time s, $mem MB"; } $times = 100000; $run1 = probe('String key', $times, function ($times) { $a = []; while ($times-- > 0) { $a["pagemanagement" . "#" . "staticblocktype" . "#" . $times . "#" . 1] = "test " . $times; } return $a; }); $run2 = probe('CRC32 key', $times, function ($times) { $a = []; while ($times-- > 0) { $a[crc32("pagemanagement" . "#" . "staticblocktype" . "#" . $times . "#" . 1)] = "test " . $times; } return $a; }); $run3 = probe('MD5 key', $times, function ($times) { $a = []; while ($times-- > 0) { $a[md5("pagemanagement" . "#" . "staticblocktype" . "#" . $times . "#" . 1)] = "test " . $times; } return $a; }); $run4 = probe('SHA1 key', $times, function ($times) { $a = []; while ($times-- > 0) { $a[sha1("pagemanagement" . "#" . "staticblocktype" . "#" . $times . "#" . 1)] = "test " . $times; } return $a; }); echo join("<br/>\n", [ $run1, $run2, $run3, $run4, ]);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/rJhob
function name:  (null)
number of ops:  39
compiled vars:  !0 = $times, !1 = $run1, !2 = $run2, !3 = $run3, !4 = $run4
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   ASSIGN                                                   !0, 100000
   14     1        INIT_FCALL                                               'probe'
          2        SEND_VAL                                                 'String+key'
          3        SEND_VAR                                                 !0
          4        DECLARE_LAMBDA_FUNCTION                          ~6      [0]
   20     5        SEND_VAL                                                 ~6
   14     6        DO_FCALL                                      0  $7      
          7        ASSIGN                                                   !1, $7
   22     8        INIT_FCALL                                               'probe'
          9        SEND_VAL                                                 'CRC32+key'
         10        SEND_VAR                                                 !0
         11        DECLARE_LAMBDA_FUNCTION                          ~9      [1]
   28    12        SEND_VAL                                                 ~9
   22    13        DO_FCALL                                      0  $10     
         14        ASSIGN                                                   !2, $10
   30    15        INIT_FCALL                                               'probe'
         16        SEND_VAL                                                 'MD5+key'
         17        SEND_VAR                                                 !0
         18        DECLARE_LAMBDA_FUNCTION                          ~12     [2]
   36    19        SEND_VAL                                                 ~12
   30    20        DO_FCALL                                      0  $13     
         21        ASSIGN                                                   !3, $13
   38    22        INIT_FCALL                                               'probe'
         23        SEND_VAL                                                 'SHA1+key'
         24        SEND_VAR                                                 !0
         25        DECLARE_LAMBDA_FUNCTION                          ~15     [3]
   44    26        SEND_VAL                                                 ~15
   38    27        DO_FCALL                                      0  $16     
         28        ASSIGN                                                   !4, $16
   47    29        INIT_FCALL                                               'join'
         30        SEND_VAL                                                 '%3Cbr%2F%3E%0A'
   48    31        INIT_ARRAY                                       ~18     !1
   49    32        ADD_ARRAY_ELEMENT                                ~18     !2
   50    33        ADD_ARRAY_ELEMENT                                ~18     !3
   51    34        ADD_ARRAY_ELEMENT                                ~18     !4
         35        SEND_VAL                                                 ~18
   47    36        DO_ICALL                                         $19     
   51    37        ECHO                                                     $19
   52    38      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
2 jumps found. (Code = 44) Position 1 = 12, Position 2 = 3
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 3
2 jumps found. (Code = 44) Position 1 = 12, Position 2 = 3
Branch analysis from position: 12
Branch analysis from position: 3
filename:       /in/rJhob
function name:  {closure}
number of ops:  14
compiled vars:  !0 = $times, !1 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
   15     1        ASSIGN                                                   !1, <array>
   16     2      > JMP                                                      ->9
   17     3    >   CONCAT                                           ~3      'pagemanagement%23staticblocktype%23', !0
          4        CONCAT                                           ~4      ~3, '%23'
          5        CONCAT                                           ~5      ~4, '1'
          6        CONCAT                                           ~7      'test+', !0
          7        ASSIGN_DIM                                               !1, ~5
          8        OP_DATA                                                  ~7
   16     9    >   POST_DEC                                         ~8      !0
         10        IS_SMALLER                                               0, ~8
         11      > JMPNZ                                                    ~9, ->3
   19    12    > > RETURN                                                   !1
   20    13*     > RETURN                                                   null

End of Dynamic Function 0

Dynamic Function 1
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
2 jumps found. (Code = 44) Position 1 = 15, Position 2 = 3
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 3
2 jumps found. (Code = 44) Position 1 = 15, Position 2 = 3
Branch analysis from position: 15
Branch analysis from position: 3
filename:       /in/rJhob
function name:  {closure}
number of ops:  17
compiled vars:  !0 = $times, !1 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   RECV                                             !0      
   23     1        ASSIGN                                                   !1, <array>
   24     2      > JMP                                                      ->12
   25     3    >   INIT_FCALL                                               'crc32'
          4        CONCAT                                           ~3      'pagemanagement%23staticblocktype%23', !0
          5        CONCAT                                           ~4      ~3, '%23'
          6        CONCAT                                           ~5      ~4, '1'
          7        SEND_VAL                                                 ~5
          8        DO_ICALL                                         $6      
          9        CONCAT                                           ~8      'test+', !0
         10        ASSIGN_DIM                                               !1, $6
         11        OP_DATA                                                  ~8
   24    12    >   POST_DEC                                         ~9      !0
         13        IS_SMALLER                                               0, ~9
         14      > JMPNZ                                                    ~10, ->3
   27    15    > > RETURN                                                   !1
   28    16*     > RETURN                                                   null

End of Dynamic Function 1

Dynamic Function 2
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
2 jumps found. (Code = 44) Position 1 = 15, Position 2 = 3
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 3
2 jumps found. (Code = 44) Position 1 = 15, Position 2 = 3
Branch analysis from position: 15
Branch analysis from position: 3
filename:       /in/rJhob
function name:  {closure}
number of ops:  17
compiled vars:  !0 = $times, !1 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   RECV                                             !0      
   31     1        ASSIGN                                                   !1, <array>
   32     2      > JMP                                                      ->12
   33     3    >   INIT_FCALL                                               'md5'
          4        CONCAT                                           ~3      'pagemanagement%23staticblocktype%23', !0
          5        CONCAT                                           ~4      ~3, '%23'
          6        CONCAT                                           ~5      ~4, '1'
          7        SEND_VAL                                                 ~5
          8        DO_ICALL                                         $6      
          9        CONCAT                                           ~8      'test+', !0
         10        ASSIGN_DIM                                               !1, $6
         11        OP_DATA                                                  ~8
   32    12    >   POST_DEC                                         ~9      !0
         13        IS_SMALLER                                               0, ~9
         14      > JMPNZ                                                    ~10, ->3
   35    15    > > RETURN                                                   !1
   36    16*     > RETURN                                                   null

End of Dynamic Function 2

Dynamic Function 3
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
2 jumps found. (Code = 44) Position 1 = 15, Position 2 = 3
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 3
2 jumps found. (Code = 44) Position 1 = 15, Position 2 = 3
Branch analysis from position: 15
Branch analysis from position: 3
filename:       /in/rJhob
function name:  {closure}
number of ops:  17
compiled vars:  !0 = $times, !1 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   38     0  E >   RECV                                             !0      
   39     1        ASSIGN                                                   !1, <array>
   40     2      > JMP                                                      ->12
   41     3    >   INIT_FCALL                                               'sha1'
          4        CONCAT                                           ~3      'pagemanagement%23staticblocktype%23', !0
          5        CONCAT                                           ~4      ~3, '%23'
          6        CONCAT                                           ~5      ~4, '1'
          7        SEND_VAL                                                 ~5
          8        DO_ICALL                                         $6      
          9        CONCAT                                           ~8      'test+', !0
         10        ASSIGN_DIM                                               !1, $6
         11        OP_DATA                                                  ~8
   40    12    >   POST_DEC                                         ~9      !0
         13        IS_SMALLER                                               0, ~9
         14      > JMPNZ                                                    ~10, ->3
   43    15    > > RETURN                                                   !1
   44    16*     > RETURN                                                   null

End of Dynamic Function 3

Function probe:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/rJhob
function name:  probe
number of ops:  37
compiled vars:  !0 = $label, !1 = $times, !2 = $callback, !3 = $mem, !4 = $start, !5 = $array, !6 = $time
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
    4     3        INIT_FCALL                                               'memory_get_usage'
          4        DO_ICALL                                         $7      
          5        ASSIGN                                                   !3, $7
    5     6        INIT_FCALL                                               'microtime'
          7        SEND_VAL                                                 <true>
          8        DO_ICALL                                         $9      
          9        ASSIGN                                                   !4, $9
    6    10        INIT_DYNAMIC_CALL                                        !2
         11        SEND_VAR_EX                                              !1
         12        DO_FCALL                                      0  $11     
         13        ASSIGN                                                   !5, $11
    7    14        INIT_FCALL                                               'microtime'
         15        SEND_VAL                                                 <true>
         16        DO_ICALL                                         $13     
         17        SUB                                              ~14     $13, !4
         18        ASSIGN                                                   !6, ~14
    8    19        INIT_FCALL                                               'sprintf'
         20        SEND_VAL                                                 '%25.3f'
         21        INIT_FCALL                                               'memory_get_usage'
         22        DO_ICALL                                         $16     
         23        SUB                                              ~17     $16, !3
         24        DIV                                              ~18     ~17, 1024
         25        DIV                                              ~19     ~18, 1024
         26        SEND_VAL                                                 ~19
         27        DO_ICALL                                         $20     
         28        ASSIGN                                                   !3, $20
    9    29        ROPE_INIT                                     6  ~23     !0
         30        ROPE_ADD                                      1  ~23     ~23, '%3A++'
         31        ROPE_ADD                                      2  ~23     ~23, !6
         32        ROPE_ADD                                      3  ~23     ~23, '+s%2C+'
         33        ROPE_ADD                                      4  ~23     ~23, !3
         34        ROPE_END                                      5  ~22     ~23, '+MB'
         35      > RETURN                                                   ~22
   10    36*     > RETURN                                                   null

End of function probe

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.77 ms | 1448 KiB | 24 Q