3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * This code will benchmark your server to determine how high of a cost you can * afford. You want to set the highest cost that you can without slowing down * you server too much. 8-10 is a good baseline, and more is good if your servers * are fast enough. The code below aims for ≤ 50 milliseconds stretching time, * which is a good baseline for systems handling interactive logins. */ $timeTarget = 0.05; // 50 milliseconds $cost = 8; do { $cost++; $start = microtime(true); password_hash("test", PASSWORD_BCRYPT, ["cost" => $cost]); $end = microtime(true); } while (($end - $start) < $timeTarget); echo "Appropriate Cost Found: " . $cost . "\n";
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 44) Position 1 = 20, Position 2 = 2
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 2
filename:       /in/kIYsR
function name:  (null)
number of ops:  24
compiled vars:  !0 = $timeTarget, !1 = $cost, !2 = $start, !3 = $end
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   ASSIGN                                                   !0, 0.05
   11     1        ASSIGN                                                   !1, 8
   13     2    >   PRE_INC                                                  !1
   14     3        INIT_FCALL                                               'microtime'
          4        SEND_VAL                                                 <true>
          5        DO_ICALL                                         $7      
          6        ASSIGN                                                   !2, $7
   15     7        INIT_FCALL                                               'password_hash'
          8        SEND_VAL                                                 'test'
          9        SEND_VAL                                                 '2y'
         10        INIT_ARRAY                                       ~9      !1, 'cost'
         11        SEND_VAL                                                 ~9
         12        DO_ICALL                                                 
   16    13        INIT_FCALL                                               'microtime'
         14        SEND_VAL                                                 <true>
         15        DO_ICALL                                         $11     
         16        ASSIGN                                                   !3, $11
   17    17        SUB                                              ~13     !3, !2
         18        IS_SMALLER                                               ~13, !0
         19      > JMPNZ                                                    ~14, ->2
   19    20    >   CONCAT                                           ~15     'Appropriate+Cost+Found%3A+', !1
         21        CONCAT                                           ~16     ~15, '%0A'
         22        ECHO                                                     ~16
         23      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
147.01 ms | 1387 KiB | 17 Q