3v4l.org

run code in 300+ PHP versions simultaneously
<?php function randomString($len) { static $dict = 'abcdefghijklmnopqrstuvwxyz/.'; $dictLen = strlen($dict) - 1; $res = ''; for ($i = 0; $i < $len; $i++) { $res .= $dict[mt_rand(0, $dictLen)]; } return $res; } $i = 0; $m = 1000; // Array items to generate. $foo = memory_get_usage(); $cache = array(); for (; $i < $m; $i++) { $cache[randomString(25)] = randomString(40); if (($i + 1) % 100 == 0) echo ($i + 1) . ': ' . (memory_get_usage() - $foo - 80) . '<br>'; // $foo is 80 bytes } echo '<hr>'; var_dump(end($cache)); echo '<hr>'; $serialized = serialize($cache); $jsond = json_encode($cache); $count = 2000; $x = microtime(1); for ($i = $count; $i--;) $y3 = json_decode($jsond, true); echo microtime(1) - $x; echo ' <- json <br>'; var_dump(end($y3)); echo '<br>'; $x = microtime(1); for ($i = $count; $i--;) $y2 = unserialize($serialized); echo microtime(1) - $x; echo ' <- unser <br>'; var_dump(end($y2)); echo '<br>'; ?>

Abusive script

This script was stopped while abusing our resources

Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 7
Branch analysis from position: 31
1 jumps found. (Code = 42) Position 1 = 59
Branch analysis from position: 59
2 jumps found. (Code = 44) Position 1 = 61, Position 2 = 54
Branch analysis from position: 61
1 jumps found. (Code = 42) Position 1 = 84
Branch analysis from position: 84
2 jumps found. (Code = 44) Position 1 = 86, Position 2 = 80
Branch analysis from position: 86
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 80
2 jumps found. (Code = 44) Position 1 = 86, Position 2 = 80
Branch analysis from position: 86
Branch analysis from position: 80
Branch analysis from position: 54
2 jumps found. (Code = 44) Position 1 = 61, Position 2 = 54
Branch analysis from position: 61
Branch analysis from position: 54
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 28
Branch analysis from position: 19
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 7
Branch analysis from position: 31
Branch analysis from position: 7
Branch analysis from position: 28
filename:       /in/grkSm
function name:  (null)
number of ops:  100
compiled vars:  !0 = $i, !1 = $m, !2 = $foo, !3 = $cache, !4 = $serialized, !5 = $jsond, !6 = $count, !7 = $x, !8 = $y3, !9 = $y2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   ASSIGN                                                   !0, 0
   13     1        ASSIGN                                                   !1, 1000
   15     2        INIT_FCALL                                               'memory_get_usage'
          3        DO_ICALL                                         $12     
          4        ASSIGN                                                   !2, $12
   17     5        ASSIGN                                                   !3, <array>
   19     6      > JMP                                                      ->29
   20     7    >   INIT_FCALL                                               'randomstring'
          8        SEND_VAL                                                 25
          9        DO_FCALL                                      0  $15     
         10        INIT_FCALL                                               'randomstring'
         11        SEND_VAL                                                 40
         12        DO_FCALL                                      0  $17     
         13        ASSIGN_DIM                                               !3, $15
         14        OP_DATA                                                  $17
   21    15        ADD                                              ~18     !0, 1
         16        MOD                                              ~19     ~18, 100
         17        IS_EQUAL                                                 ~19, 0
         18      > JMPZ                                                     ~20, ->28
         19    >   ADD                                              ~21     !0, 1
         20        CONCAT                                           ~22     ~21, '%3A+'
         21        INIT_FCALL                                               'memory_get_usage'
         22        DO_ICALL                                         $23     
         23        SUB                                              ~24     $23, !2
         24        SUB                                              ~25     ~24, 80
         25        CONCAT                                           ~26     ~22, ~25
         26        CONCAT                                           ~27     ~26, '%3Cbr%3E'
         27        ECHO                                                     ~27
   19    28    >   PRE_INC                                                  !0
         29    >   IS_SMALLER                                               !0, !1
         30      > JMPNZ                                                    ~29, ->7
   24    31    >   ECHO                                                     '%3Chr%3E'
   25    32        INIT_FCALL                                               'var_dump'
         33        INIT_FCALL                                               'end'
         34        SEND_REF                                                 !3
         35        DO_ICALL                                         $30     
         36        SEND_VAR                                                 $30
         37        DO_ICALL                                                 
   26    38        ECHO                                                     '%3Chr%3E'
   28    39        INIT_FCALL                                               'serialize'
         40        SEND_VAR                                                 !3
         41        DO_ICALL                                         $32     
         42        ASSIGN                                                   !4, $32
   29    43        INIT_FCALL                                               'json_encode'
         44        SEND_VAR                                                 !3
         45        DO_ICALL                                         $34     
         46        ASSIGN                                                   !5, $34
   31    47        ASSIGN                                                   !6, 2000
   33    48        INIT_FCALL                                               'microtime'
         49        SEND_VAL                                                 1
         50        DO_ICALL                                         $37     
         51        ASSIGN                                                   !7, $37
   34    52        ASSIGN                                                   !0, !6
         53      > JMP                                                      ->59
         54    >   INIT_FCALL                                               'json_decode'
         55        SEND_VAR                                                 !5
         56        SEND_VAL                                                 <true>
         57        DO_ICALL                                         $40     
         58        ASSIGN                                                   !8, $40
         59    >   POST_DEC                                         ~42     !0
         60      > JMPNZ                                                    ~42, ->54
   35    61    >   INIT_FCALL                                               'microtime'
         62        SEND_VAL                                                 1
         63        DO_ICALL                                         $43     
         64        SUB                                              ~44     $43, !7
         65        ECHO                                                     ~44
   36    66        ECHO                                                     '+%3C-+json+%3Cbr%3E'
   37    67        INIT_FCALL                                               'var_dump'
         68        INIT_FCALL                                               'end'
         69        SEND_REF                                                 !8
         70        DO_ICALL                                         $45     
         71        SEND_VAR                                                 $45
         72        DO_ICALL                                                 
   38    73        ECHO                                                     '%3Cbr%3E'
   40    74        INIT_FCALL                                               'microtime'
         75        SEND_VAL                                                 1
         76        DO_ICALL                                         $47     
         77        ASSIGN                                                   !7, $47
   41    78        ASSIGN                                                   !0, !6
         79      > JMP                                                      ->84
         80    >   INIT_FCALL                                               'unserialize'
         81        SEND_VAR                                                 !4
         82        DO_ICALL                                         $50     
         83        ASSIGN                                                   !9, $50
         84    >   POST_DEC                                         ~52     !0
         85      > JMPNZ                                                    ~52, ->80
   42    86    >   INIT_FCALL                                               'microtime'
         87        SEND_VAL                                                 1
         88        DO_ICALL                                         $53     
         89        SUB                                              ~54     $53, !7
         90        ECHO                                                     ~54
   43    91        ECHO                                                     '+%3C-+unser+%3Cbr%3E'
   44    92        INIT_FCALL                                               'var_dump'
         93        INIT_FCALL                                               'end'
         94        SEND_REF                                                 !9
         95        DO_ICALL                                         $55     
         96        SEND_VAR                                                 $55
         97        DO_ICALL                                                 
   45    98        ECHO                                                     '%3Cbr%3E'
   47    99      > RETURN                                                   1

Function randomstring:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
2 jumps found. (Code = 44) Position 1 = 17, Position 2 = 8
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
2 jumps found. (Code = 44) Position 1 = 17, Position 2 = 8
Branch analysis from position: 17
Branch analysis from position: 8
filename:       /in/grkSm
function name:  randomString
number of ops:  19
compiled vars:  !0 = $len, !1 = $dict, !2 = $dictLen, !3 = $res, !4 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    3     1        BIND_STATIC                                              !1
    4     2        STRLEN                                           ~5      !1
          3        SUB                                              ~6      ~5, 1
          4        ASSIGN                                                   !2, ~6
    5     5        ASSIGN                                                   !3, ''
    6     6        ASSIGN                                                   !4, 0
          7      > JMP                                                      ->15
    7     8    >   INIT_FCALL                                               'mt_rand'
          9        SEND_VAL                                                 0
         10        SEND_VAR                                                 !2
         11        DO_ICALL                                         $10     
         12        FETCH_DIM_R                                      ~11     !1, $10
         13        ASSIGN_OP                                     8          !3, ~11
    6    14        PRE_INC                                                  !4
         15    >   IS_SMALLER                                               !4, !0
         16      > JMPNZ                                                    ~14, ->8
    9    17    > > RETURN                                                   !3
   10    18*     > RETURN                                                   null

End of function randomstring

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.6 ms | 1407 KiB | 33 Q