diff options
Diffstat (limited to 'bench.php')
| -rw-r--r-- | bench.php | 72 | 
1 files changed, 43 insertions, 29 deletions
| @@ -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); - | 
