3v4l.org

run code in 300+ PHP versions simultaneously
<?php function bcryptWithCost($cost) { $cost = str_pad($cost, 2, '0', STR_PAD_LEFT); crypt('password', '$2y$' . $cost . '$thisisasaltthisisasalt'); } $costs = range(9, 15); foreach ($costs as $cost) { $timestamp = microtime(true); bcryptWithCost($cost); $time = microtime(true) - $timestamp; echo $cost . ' ' . $time . PHP_EOL; if (!isset($recommended) && $time >= 0.5) { $recommended = $cost; } if (isset($recommended) && $time < 0.9) { $recommended = $cost; } } echo "recommended cost param for this environment: $recommended\n";
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 37
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 37
Branch analysis from position: 7
2 jumps found. (Code = 46) Position 1 = 26, Position 2 = 28
Branch analysis from position: 26
2 jumps found. (Code = 43) Position 1 = 29, Position 2 = 30
Branch analysis from position: 29
2 jumps found. (Code = 46) Position 1 = 32, Position 2 = 34
Branch analysis from position: 32
2 jumps found. (Code = 43) Position 1 = 35, Position 2 = 36
Branch analysis from position: 35
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 36
Branch analysis from position: 34
Branch analysis from position: 30
Branch analysis from position: 28
Branch analysis from position: 37
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 37
filename:       /in/I0Qrf
function name:  (null)
number of ops:  43
compiled vars:  !0 = $costs, !1 = $cost, !2 = $timestamp, !3 = $time, !4 = $recommended
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   INIT_FCALL                                               'range'
          1        SEND_VAL                                                 9
          2        SEND_VAL                                                 15
          3        DO_ICALL                                         $5      
          4        ASSIGN                                                   !0, $5
   10     5      > FE_RESET_R                                       $7      !0, ->37
          6    > > FE_FETCH_R                                               $7, !1, ->37
   11     7    >   INIT_FCALL                                               'microtime'
          8        SEND_VAL                                                 <true>
          9        DO_ICALL                                         $8      
         10        ASSIGN                                                   !2, $8
   12    11        INIT_FCALL                                               'bcryptwithcost'
         12        SEND_VAR                                                 !1
         13        DO_FCALL                                      0          
   13    14        INIT_FCALL                                               'microtime'
         15        SEND_VAL                                                 <true>
         16        DO_ICALL                                         $11     
         17        SUB                                              ~12     $11, !2
         18        ASSIGN                                                   !3, ~12
   14    19        CONCAT                                           ~14     !1, '+'
         20        CONCAT                                           ~15     ~14, !3
         21        CONCAT                                           ~16     ~15, '%0A'
         22        ECHO                                                     ~16
   15    23        ISSET_ISEMPTY_CV                                 ~17     !4
         24        BOOL_NOT                                         ~18     ~17
         25      > JMPZ_EX                                          ~18     ~18, ->28
         26    >   IS_SMALLER_OR_EQUAL                              ~19     0.5, !3
         27        BOOL                                             ~18     ~19
         28    > > JMPZ                                                     ~18, ->30
   16    29    >   ASSIGN                                                   !4, !1
   18    30    >   ISSET_ISEMPTY_CV                                 ~21     !4
         31      > JMPZ_EX                                          ~21     ~21, ->34
         32    >   IS_SMALLER                                       ~22     !3, 0.9
         33        BOOL                                             ~21     ~22
         34    > > JMPZ                                                     ~21, ->36
   19    35    >   ASSIGN                                                   !4, !1
   10    36    > > JMP                                                      ->6
         37    >   FE_FREE                                                  $7
   23    38        ROPE_INIT                                     3  ~25     'recommended+cost+param+for+this+environment%3A+'
         39        ROPE_ADD                                      1  ~25     ~25, !4
         40        ROPE_END                                      2  ~24     ~25, '%0A'
         41        ECHO                                                     ~24
         42      > RETURN                                                   1

Function bcryptwithcost:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/I0Qrf
function name:  bcryptWithCost
number of ops:  15
compiled vars:  !0 = $cost
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        INIT_FCALL                                               'str_pad'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 2
          4        SEND_VAL                                                 '0'
          5        SEND_VAL                                                 0
          6        DO_ICALL                                         $1      
          7        ASSIGN                                                   !0, $1
    5     8        INIT_FCALL                                               'crypt'
          9        SEND_VAL                                                 'password'
         10        CONCAT                                           ~3      '%242y%24', !0
         11        CONCAT                                           ~4      ~3, '%24thisisasaltthisisasalt'
         12        SEND_VAL                                                 ~4
         13        DO_ICALL                                                 
    6    14      > RETURN                                                   null

End of function bcryptwithcost

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
146.93 ms | 1394 KiB | 22 Q