Skip to content

Instantly share code, notes, and snippets.

@Clarence-pan
Created May 31, 2017 09:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Clarence-pan/4c05fd2ea3f31722fa6910bc82976c08 to your computer and use it in GitHub Desktop.
Save Clarence-pan/4c05fd2ea3f31722fa6910bc82976c08 to your computer and use it in GitHub Desktop.
测试bcrypt的速度
<?php
echo sprintf("%10s %10s\n", 'cost', 'time');
for ($cost = 8; $cost < 20; $cost++) {
$begin = microtime(true);
password_hash('test1234', PASSWORD_BCRYPT, ['cost' => $cost]);
$delta = microtime(true) - $begin;
echo sprintf("%10d %10.6f\n", $cost, $delta);
}
cost time
8 0.021307
9 0.037150
10 0.079283
11 0.175612
12 0.317375
13 0.663080
14 1.330451
15 2.245152
16 4.291169
17 8.318790
18 16.472902
19 35.146999
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment