summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bench.php72
1 files changed, 43 insertions, 29 deletions
diff --git a/bench.php b/bench.php
index a5bc09b..00df9d6 100644
--- a/bench.php
+++ b/bench.php
@@ -1,37 +1,51 @@
<?php
-$deb = microtime(true);
-echo 'PASSWORD_BCRYPT: ';
-for($i=0; $i<10; $i++) {
- $h = password_hash("secret$i", PASSWORD_BCRYPT);
+if (defined("PASSWORD_BCRYPT")) {
+ $deb = microtime(true);
+ echo 'PASSWORD_BCRYPT: ';
+ for($i=0; $i<10; $i++) {
+ $h = password_hash("secret$i", PASSWORD_BCRYPT);
+ }
+ printf("%.3f\"\n", microtime(true) - $deb);
}
-printf("%.3f\"\n", microtime(true) - $deb);
-
-$deb = microtime(true);
-echo 'PASSWORD_ARGON2I: ';
-for($i=0; $i<10; $i++) {
- $h = password_hash("secret$i", PASSWORD_ARGON2I);
+if (defined("PASSWORD_ARGON2I")) {
+ $deb = microtime(true);
+ echo 'PASSWORD_ARGON2I: ';
+ for($i=0; $i<10; $i++) {
+ $h = password_hash("secret$i", PASSWORD_ARGON2I);
+ }
+ printf("%.3f\"\n", microtime(true) - $deb);
}
-printf("%.3f\"\n", microtime(true) - $deb);
-
-$deb = microtime(true);
-echo 'PASSWORD_ARGON2ID: ';
-for($i=0; $i<10; $i++) {
- $h = password_hash("secret$i", PASSWORD_ARGON2ID);
+if (defined("PASSWORD_ARGON2ID")) {
+ $deb = microtime(true);
+ echo 'PASSWORD_ARGON2ID: ';
+ for($i=0; $i<10; $i++) {
+ $h = password_hash("secret$i", PASSWORD_ARGON2ID);
+ }
+ printf("%.3f\"\n", microtime(true) - $deb);
}
-printf("%.3f\"\n", microtime(true) - $deb);
-
-$deb = microtime(true);
-echo 'PASSWORD_SHA512: ';
-for($i=0; $i<10; $i++) {
- $h = password_hash("secret$i", PASSWORD_SHA512);
+if (defined("PASSWORD_SHA512")) {
+ $deb = microtime(true);
+ echo 'PASSWORD_SHA512: ';
+ for($i=0; $i<10; $i++) {
+ $h = password_hash("secret$i", PASSWORD_SHA512);
+ }
+ printf("%.3f\"\n", microtime(true) - $deb);
}
-printf("%.3f\"\n", microtime(true) - $deb);
+if (defined("PASSWORD_YESCRYPT")) {
+ $deb = microtime(true);
+ echo 'PASSWORD_YESCRYPT: ';
+ for($i=0; $i<10; $i++) {
+ $h = password_hash("secret$i", PASSWORD_YESCRYPT);
+ }
+ printf("%.3f\"\n", microtime(true) - $deb);
-$deb = microtime(true);
-echo 'PASSWORD_YESCRYPT: ';
-for($i=0; $i<10; $i++) {
- $h = password_hash("secret$i", PASSWORD_YESCRYPT);
+ for($c=0; $c<12; $c++) {
+ $deb = microtime(true);
+ echo "PASSWORD_YESCRYPT(cost=$c): ";
+ for($i=1; $i<10; $i++) {
+ $h = password_hash("secret$i$c", PASSWORD_YESCRYPT, ['cost'=>$c]);
+ }
+ printf("%.3f\"\n", microtime(true) - $deb);
+ }
}
-printf("%.3f\"\n", microtime(true) - $deb);
-