-
Notifications
You must be signed in to change notification settings - Fork 38
Added a benchmark for the bcrypt cost parameter + fixed a unit test #26
Added a benchmark for the bcrypt cost parameter + fixed a unit test #26
Conversation
@@ -44,6 +45,9 @@ public function testHas($symmetric) | |||
public function testGet($symmetric) | |||
{ | |||
$plugin = new SymmetricPluginManager(); | |||
if (! extension_loaded($symmetric)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the extension_loaded check can be placed before new SymmetricPluginManager
creation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@samsonasik why? The symmetric plugins are loaded only on the get()
execution, not in the constructor of SymmetricPluginManager
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can skip the instantiation step if extension not loaded, and set expected exception, because in next line, the extension used in the tests.
Warm regards,
Abdul Malik Ikhsan
Pada 6 Mei 2016, pukul 15.44, Enrico Zimuel [email protected] menulis:
In test/SymmetricPluginManagerTest.php:
@@ -44,6 +45,9 @@ public function testHas($symmetric)
public function testGet($symmetric)
{
$plugin = new SymmetricPluginManager();
@samsonasik why? The symmetric plugins are loaded only on the get() execution, not in the constructor of SymmetricPluginManager.if (! extension_loaded($symmetric)) {
—
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@samsonasik ok, I will move it, not a big difference anyway.
@weierophinney this PR is ready for review, thanks! |
Added a benchmark for the bcrypt cost parameter + fixed a unit test
This PR adds a benchmark function in
Zend\Crypt\Password\Bcrypt
to test the cost parameter on a time to target. This function can be used to choose the bcrypt cost parameter to use in your environment.The default time to target is 0.05 seconds (50 milliseconds) that is which is a good baseline for systems handling interactive logins. On my environment: CPU Intel i5-2500 at 3.30GHz, 8 GB RAM, the result of the benchmark is cost 10 (the default value of
Zend\Crypt\Password\Bcrypt
and PHP).Note: this function uses the same code reported in example 4 of password_hash() in the PHP online manual.