3v4l.org

run code in 500+ PHP versions simultaneously
<?php set_time_limit(0); ### Helpers: function print_mem() { /* Currently used memory */ $mem_usage = memory_get_usage(); /* Peak memory usage */ $mem_peak = memory_get_peak_usage(); echo " " . 'The script is now using: ' . $mem_usage . " B of memory.\n"; echo " " . 'The script is now using: ' . round($mem_usage / 1024) . " KB of memory.\n"; echo " " . "Peak usage: " . round($mem_peak / 1024) . " KB of memory.\n"; } function get_formatted_microtime($time) { $to_format = DateTime::createFromFormat('U.u', sprintf("%.6F", $time)); $formatted = $to_format->format("Y-m-d H:i:s.u"); return $formatted; } ### Load Config: $time_start = microtime(true); // Loading configuration $config = parse_ini_file("config.ini", true); $time_end = microtime(true); $time = ($time_end - $time_start) * 1000; ### Merge CLI parameters into $_GET: if (isset($config['common-parameters'])) { foreach($config['common-parameters'] as $key => $value) { if (!isset($_GET[$key])) { $_GET[$key] = $value; } } } if (!empty($argv)) { parse_str(implode('&', array_slice($argv, 1)), $cli_arguments); $_GET = array_merge($_GET, $cli_arguments); } ### if (empty($argv)) { echo "<pre>\n"; } ### Connect to the database: $iteration = 0; $number_of_iterations = (int) $_GET['number_of_iterations']; while (true) { $iteration++; ### Actual Connection Time: $connection_attempt_start = microtime(true); $connection_attempt_start_formatted = get_formatted_microtime($connection_attempt_start); $was_connection_successful = false; try { echo "Before PDO Connection Attempt:\n"; print_mem(); // Creating MySQL Connection: $port = (int) $config['database']['port']; $dsn = "mysql:host={$config['database']['host']};dbname={$config['database']['database']};port={$port}"; $options = []; if ((bool) $config['database']['use_ssl']) { $options[PDO::MYSQL_ATTR_SSL_CA] = $config['ca_root_path']; } $pdo = new PDO($dsn, $config['database']['username'], $config['database']['password'], $options); $was_connection_successful = true; } catch (PDOException $e) { echo $e->code . ' ' . $e->message . "\n"; $was_connection_successful = false; } echo "After PDO Connection Attempt:\n"; print_mem(); $connection_attempt_end = microtime(true); $connection_attempt_end_formatted = get_formatted_microtime($connection_attempt_end); $connection_time = ($connection_attempt_end - $connection_attempt_start) * 1000; if ((bool)$_GET['show_output']) { if ($was_connection_successful) { echo "{$iteration}. Connected to database ({$config['database']['host']}) in $connection_time milliseconds.\n"; } else { echo "{$iteration}. Connection attempt to database ({$config['database']['host']}) failed after $connection_time milliseconds. Sleeping for 3 seconds.\n"; sleep(3); } } unset($pdo); if ($number_of_iterations !== 0 && $iteration >= $number_of_iterations) { break; } if (isset($_GET['iteration_delay']) && $_GET['iteration_delay'] > 0) { sleep((int) $_GET['iteration_delay']); } echo "Iteration finished: \n"; print_mem(); } if (empty($argv)) { echo "\n</pre>"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 34
Branch analysis from position: 21
2 jumps found. (Code = 77) Position 1 = 23, Position 2 = 33
Branch analysis from position: 23
2 jumps found. (Code = 78) Position 1 = 24, Position 2 = 33
Branch analysis from position: 24
2 jumps found. (Code = 43) Position 1 = 29, Position 2 = 32
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
Branch analysis from position: 32
Branch analysis from position: 33
2 jumps found. (Code = 43) Position 1 = 37, Position 2 = 53
Branch analysis from position: 37
2 jumps found. (Code = 43) Position 1 = 55, Position 2 = 56
Branch analysis from position: 55
1 jumps found. (Code = 42) Position 1 = 187
Branch analysis from position: 187
2 jumps found. (Code = 44) Position 1 = 188, Position 2 = 62
Branch analysis from position: 188
2 jumps found. (Code = 43) Position 1 = 190, Position 2 = 191
Branch analysis from position: 190
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 191
Branch analysis from position: 62
2 jumps found. (Code = 43) Position 1 = 95, Position 2 = 99
Branch analysis from position: 95
1 jumps found. (Code = 42) Position 1 = 122
Branch analysis from position: 122
2 jumps found. (Code = 43) Position 1 = 140, Position 2 = 163
Branch analysis from position: 140
2 jumps found. (Code = 43) Position 1 = 141, Position 2 = 151
Branch analysis from position: 141
1 jumps found. (Code = 42) Position 1 = 163
Branch analysis from position: 163
2 jumps found. (Code = 46) Position 1 = 166, Position 2 = 168
Branch analysis from position: 166
2 jumps found. (Code = 43) Position 1 = 169, Position 2 = 170
Branch analysis from position: 169
1 jumps found. (Code = 42) Position 1 = 188
Branch analysis from position: 188
Branch analysis from position: 170
2 jumps found. (Code = 46) Position 1 = 173, Position 2 = 177
Branch analysis from position: 173
2 jumps found. (Code = 43) Position 1 = 178, Position 2 = 184
Branch analysis from position: 178
2 jumps found. (Code = 44) Position 1 = 188, Position 2 = 62
Branch analysis from position: 188
Branch analysis from position: 62
Branch analysis from position: 184
Branch analysis from position: 177
Branch analysis from position: 168
Branch analysis from position: 151
2 jumps found. (Code = 46) Position 1 = 166, Position 2 = 168
Branch analysis from position: 166
Branch analysis from position: 168
Branch analysis from position: 163
Branch analysis from position: 99
Branch analysis from position: 56
Branch analysis from position: 53
Branch analysis from position: 33
Branch analysis from position: 34
Found catch point at position: 114
Branch analysis from position: 114
2 jumps found. (Code = 107) Position 1 = 115, Position 2 = -2
Branch analysis from position: 115
2 jumps found. (Code = 43) Position 1 = 140, Position 2 = 163
Branch analysis from position: 140
Branch analysis from position: 163
filename:       /in/BOnq5
function name:  (null)
number of ops:  192
compiled vars:  !0 = $time_start, !1 = $config, !2 = $time_end, !3 = $time, !4 = $value, !5 = $key, !6 = $argv, !7 = $cli_arguments, !8 = $iteration, !9 = $number_of_iterations, !10 = $connection_attempt_start, !11 = $connection_attempt_start_formatted, !12 = $was_connection_successful, !13 = $port, !14 = $dsn, !15 = $options, !16 = $pdo, !17 = $e, !18 = $connection_attempt_end, !19 = $connection_attempt_end_formatted, !20 = $connection_time
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                                   'set_time_limit'
          1        SEND_VAL                                                     0
          2        DO_ICALL                                                     
   30     3        INIT_FCALL                                                   'microtime'
          4        SEND_VAL                                                     <true>
          5        DO_ICALL                                             $22     
          6        ASSIGN                                                       !0, $22
   33     7        INIT_FCALL                                                   'parse_ini_file'
          8        SEND_VAL                                                     'config.ini'
          9        SEND_VAL                                                     <true>
         10        DO_ICALL                                             $24     
         11        ASSIGN                                                       !1, $24
   35    12        INIT_FCALL                                                   'microtime'
         13        SEND_VAL                                                     <true>
         14        DO_ICALL                                             $26     
         15        ASSIGN                                                       !2, $26
   36    16        SUB                                                  ~28     !2, !0
         17        MUL                                                  ~29     ~28, 1000
         18        ASSIGN                                                       !3, ~29
   40    19        ISSET_ISEMPTY_DIM_OBJ                             0          !1, 'common-parameters'
         20      > JMPZ                                                         ~31, ->34
   41    21    >   FETCH_DIM_R                                          ~32     !1, 'common-parameters'
         22      > FE_RESET_R                                           $33     ~32, ->33
         23    > > FE_FETCH_R                                           ~34     $33, !4, ->33
         24    >   ASSIGN                                                       !5, ~34
   42    25        FETCH_IS                                             ~36     '_GET'
         26        ISSET_ISEMPTY_DIM_OBJ                             0  ~37     ~36, !5
         27        BOOL_NOT                                             ~38     ~37
         28      > JMPZ                                                         ~38, ->32
   43    29    >   FETCH_W                          global              $39     '_GET'
         30        ASSIGN_DIM                                                   $39, !5
         31        OP_DATA                                                      !4
   41    32    > > JMP                                                          ->23
         33    >   FE_FREE                                                      $33
   48    34    >   ISSET_ISEMPTY_CV                                     ~41     !6
         35        BOOL_NOT                                             ~42     ~41
         36      > JMPZ                                                         ~42, ->53
   49    37    >   INIT_FCALL                                                   'parse_str'
         38        INIT_FCALL                                                   'array_slice'
         39        SEND_VAR                                                     !6
         40        SEND_VAL                                                     1
         41        DO_ICALL                                             $43     
         42        FRAMELESS_ICALL_2                implode             ~44     '%26', $43
         43        SEND_VAL                                                     ~44
         44        SEND_REF                                                     !7
         45        DO_ICALL                                                     
   50    46        INIT_FCALL                                                   'array_merge'
         47        FETCH_R                          global              ~47     '_GET'
         48        SEND_VAL                                                     ~47
         49        SEND_VAR                                                     !7
         50        DO_ICALL                                             $48     
         51        FETCH_W                          global              $46     '_GET'
         52        ASSIGN                                                       $46, $48
   55    53    >   ISSET_ISEMPTY_CV                                             !6
         54      > JMPZ                                                         ~50, ->56
   56    55    >   ECHO                                                         '%3Cpre%3E%0A'
   61    56    >   ASSIGN                                                       !8, 0
   62    57        FETCH_R                          global              ~52     '_GET'
         58        FETCH_DIM_R                                          ~53     ~52, 'number_of_iterations'
         59        CAST                                              4  ~54     ~53
         60        ASSIGN                                                       !9, ~54
   64    61      > JMP                                                          ->187
   66    62    >   PRE_INC                                                      !8
   70    63        INIT_FCALL                                                   'microtime'
         64        SEND_VAL                                                     <true>
         65        DO_ICALL                                             $57     
         66        ASSIGN                                                       !10, $57
   71    67        INIT_FCALL                                                   'get_formatted_microtime'
         68        SEND_VAR                                                     !10
         69        DO_FCALL                                          0  $59     
         70        ASSIGN                                                       !11, $59
   73    71        ASSIGN                                                       !12, <false>
   76    72        ECHO                                                         'Before+PDO+Connection+Attempt%3A%0A'
   77    73        INIT_FCALL                                                   'print_mem'
         74        DO_FCALL                                          0          
   79    75        FETCH_DIM_R                                          ~63     !1, 'database'
         76        FETCH_DIM_R                                          ~64     ~63, 'port'
         77        CAST                                              4  ~65     ~64
         78        ASSIGN                                                       !13, ~65
   80    79        ROPE_INIT                                         6  ~72     'mysql%3Ahost%3D'
         80        FETCH_DIM_R                                          ~67     !1, 'database'
         81        FETCH_DIM_R                                          ~68     ~67, 'host'
         82        ROPE_ADD                                          1  ~72     ~72, ~68
         83        ROPE_ADD                                          2  ~72     ~72, '%3Bdbname%3D'
         84        FETCH_DIM_R                                          ~69     !1, 'database'
         85        FETCH_DIM_R                                          ~70     ~69, 'database'
         86        ROPE_ADD                                          3  ~72     ~72, ~70
         87        ROPE_ADD                                          4  ~72     ~72, '%3Bport%3D'
         88        ROPE_END                                          5  ~71     ~72, !13
         89        ASSIGN                                                       !14, ~71
   82    90        ASSIGN                                                       !15, <array>
   83    91        FETCH_DIM_R                                          ~77     !1, 'database'
         92        FETCH_DIM_R                                          ~78     ~77, 'use_ssl'
         93        BOOL                                                 ~79     ~78
         94      > JMPZ                                                         ~79, ->99
   84    95    >   FETCH_CLASS_CONSTANT                                 ~80     'PDO', 'MYSQL_ATTR_SSL_CA'
         96        FETCH_DIM_R                                          ~82     !1, 'ca_root_path'
         97        ASSIGN_DIM                                                   !15, ~80
         98        OP_DATA                                                      ~82
   87    99    >   NEW                                                  $83     'PDO'
        100        SEND_VAR_EX                                                  !14
        101        CHECK_FUNC_ARG                                               
        102        FETCH_DIM_FUNC_ARG                                   $84     !1, 'database'
        103        FETCH_DIM_FUNC_ARG                                   $85     $84, 'username'
        104        SEND_FUNC_ARG                                                $85
        105        CHECK_FUNC_ARG                                               
        106        FETCH_DIM_FUNC_ARG                                   $86     !1, 'database'
        107        FETCH_DIM_FUNC_ARG                                   $87     $86, 'password'
        108        SEND_FUNC_ARG                                                $87
        109        SEND_VAR_EX                                                  !15
        110        DO_FCALL                                          0          
        111        ASSIGN                                                       !16, $83
   89   112        ASSIGN                                                       !12, <true>
        113      > JMP                                                          ->122
   91   114  E > > CATCH                                           last         'PDOException'
   92   115    >   FETCH_OBJ_R                                          ~91     !17, 'code'
        116        CONCAT                                               ~92     ~91, '+'
        117        FETCH_OBJ_R                                          ~93     !17, 'message'
        118        CONCAT                                               ~94     ~92, ~93
        119        CONCAT                                               ~95     ~94, '%0A'
        120        ECHO                                                         ~95
   93   121        ASSIGN                                                       !12, <false>
   96   122    >   ECHO                                                         'After+PDO+Connection+Attempt%3A%0A'
   97   123        INIT_FCALL                                                   'print_mem'
        124        DO_FCALL                                          0          
   99   125        INIT_FCALL                                                   'microtime'
        126        SEND_VAL                                                     <true>
        127        DO_ICALL                                             $98     
        128        ASSIGN                                                       !18, $98
  100   129        INIT_FCALL                                                   'get_formatted_microtime'
        130        SEND_VAR                                                     !18
        131        DO_FCALL                                          0  $100    
        132        ASSIGN                                                       !19, $100
  101   133        SUB                                                  ~102    !18, !10
        134        MUL                                                  ~103    ~102, 1000
        135        ASSIGN                                                       !20, ~103
  104   136        FETCH_R                          global              ~105    '_GET'
        137        FETCH_DIM_R                                          ~106    ~105, 'show_output'
        138        BOOL                                                 ~107    ~106
        139      > JMPZ                                                         ~107, ->163
  105   140    > > JMPZ                                                         !12, ->151
  106   141    >   ROPE_INIT                                         6  ~111    !8
        142        ROPE_ADD                                          1  ~111    ~111, '.+Connected+to+database+%28'
        143        FETCH_DIM_R                                          ~108    !1, 'database'
        144        FETCH_DIM_R                                          ~109    ~108, 'host'
        145        ROPE_ADD                                          2  ~111    ~111, ~109
        146        ROPE_ADD                                          3  ~111    ~111, '%29+in+'
        147        ROPE_ADD                                          4  ~111    ~111, !20
        148        ROPE_END                                          5  ~110    ~111, '+milliseconds.%0A'
        149        ECHO                                                         ~110
  105   150      > JMP                                                          ->163
  108   151    >   ROPE_INIT                                         6  ~117    !8
        152        ROPE_ADD                                          1  ~117    ~117, '.+Connection+attempt+to+database+%28'
        153        FETCH_DIM_R                                          ~114    !1, 'database'
        154        FETCH_DIM_R                                          ~115    ~114, 'host'
        155        ROPE_ADD                                          2  ~117    ~117, ~115
        156        ROPE_ADD                                          3  ~117    ~117, '%29+failed+after+'
        157        ROPE_ADD                                          4  ~117    ~117, !20
        158        ROPE_END                                          5  ~116    ~117, '+milliseconds.+Sleeping+for+3+seconds.%0A'
        159        ECHO                                                         ~116
  109   160        INIT_FCALL                                                   'sleep'
        161        SEND_VAL                                                     3
        162        DO_ICALL                                                     
  113   163    >   UNSET_CV                                                     !16
  115   164        IS_NOT_IDENTICAL                                     ~121    !9, 0
        165      > JMPZ_EX                                              ~121    ~121, ->168
        166    >   IS_SMALLER_OR_EQUAL                                  ~122    !9, !8
        167        BOOL                                                 ~121    ~122
        168    > > JMPZ                                                         ~121, ->170
  116   169    > > JMP                                                          ->188
  119   170    >   FETCH_IS                                             ~123    '_GET'
        171        ISSET_ISEMPTY_DIM_OBJ                             0  ~124    ~123, 'iteration_delay'
        172      > JMPZ_EX                                              ~124    ~124, ->177
        173    >   FETCH_R                          global              ~125    '_GET'
        174        FETCH_DIM_R                                          ~126    ~125, 'iteration_delay'
        175        IS_SMALLER                                           ~127    0, ~126
        176        BOOL                                                 ~124    ~127
        177    > > JMPZ                                                         ~124, ->184
  120   178    >   INIT_FCALL                                                   'sleep'
        179        FETCH_R                          global              ~128    '_GET'
        180        FETCH_DIM_R                                          ~129    ~128, 'iteration_delay'
        181        CAST                                              4  ~130    ~129
        182        SEND_VAL                                                     ~130
        183        DO_ICALL                                                     
  123   184    >   ECHO                                                         'Iteration+finished%3A+%0A'
  124   185        INIT_FCALL                                                   'print_mem'
        186        DO_FCALL                                          0          
   64   187    > > JMPNZ                                                        <true>, ->62
  127   188    >   ISSET_ISEMPTY_CV                                             !6
        189      > JMPZ                                                         ~133, ->191
  128   190    >   ECHO                                                         '%0A%3C%2Fpre%3E'
  129   191    > > RETURN                                                       1

Function print_mem:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BOnq5
function name:  print_mem
number of ops:  24
compiled vars:  !0 = $mem_usage, !1 = $mem_peak
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   10     0  E >   INIT_FCALL                                                   'memory_get_usage'
          1        DO_ICALL                                             $2      
          2        ASSIGN                                                       !0, $2
   13     3        INIT_FCALL                                                   'memory_get_peak_usage'
          4        DO_ICALL                                             $4      
          5        ASSIGN                                                       !1, $4
   15     6        CONCAT                                               ~6      '++++The+script+is+now+using%3A+', !0
          7        CONCAT                                               ~7      ~6, '+B+of+memory.%0A'
          8        ECHO                                                         ~7
   16     9        INIT_FCALL                                                   'round'
         10        DIV                                                  ~8      !0, 1024
         11        SEND_VAL                                                     ~8
         12        DO_ICALL                                             $9      
         13        CONCAT                                               ~10     '++++The+script+is+now+using%3A+', $9
         14        CONCAT                                               ~11     ~10, '+KB+of+memory.%0A'
         15        ECHO                                                         ~11
   17    16        INIT_FCALL                                                   'round'
         17        DIV                                                  ~12     !1, 1024
         18        SEND_VAL                                                     ~12
         19        DO_ICALL                                             $13     
         20        CONCAT                                               ~14     '++++Peak+usage%3A+', $13
         21        CONCAT                                               ~15     ~14, '+KB+of+memory.%0A'
         22        ECHO                                                         ~15
   18    23      > RETURN                                                       null

End of function print_mem

Function get_formatted_microtime:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BOnq5
function name:  get_formatted_microtime
number of ops:  16
compiled vars:  !0 = $time, !1 = $to_format, !2 = $formatted
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   20     0  E >   RECV                                                 !0      
   21     1        INIT_STATIC_METHOD_CALL                                      'DateTime', 'createFromFormat'
          2        SEND_VAL                                                     'U.u'
          3        INIT_FCALL                                                   'sprintf'
          4        SEND_VAL                                                     '%25.6F'
          5        SEND_VAR                                                     !0
          6        DO_ICALL                                             $3      
          7        SEND_VAR                                                     $3
          8        DO_FCALL                                          0  $4      
          9        ASSIGN                                                       !1, $4
   23    10        INIT_METHOD_CALL                                             !1, 'format'
         11        SEND_VAL_EX                                                  'Y-m-d+H%3Ai%3As.u'
         12        DO_FCALL                                          0  $6      
         13        ASSIGN                                                       !2, $6
   25    14      > RETURN                                                       !2
   26    15*     > RETURN                                                       null

End of function get_formatted_microtime

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
135.3 ms | 516 KiB | 23 Q