Closed TanukiSharp closed 5 years ago
@TanukiSharp this is great, thank you! I've merged it in https://github.com/brendanashworth/generate-password/commit/ea642553c5ba327989f36d0b0f2d4e80ff25b45a and am releasing a patch release with the change. Cheers 🍻
Waow that was fast, awesome, thank you :)
I would like to propose a good optimization for a few code change.
Here the sample code I used to benchmark the gain:
With the optimization, the code (
func2
) runs about 67 times faster.And hereafter is another benchmark code to find the best
RANDOM_BATCH_SIZE
:Running this gave me the following result:
We can see that beyond 256, the gain still gets bigger but isn't really significant to justify allocating more memory. Maybe this can be made configurable.
Note that with the values I obtained, it can run up to 96 times faster.
Please don't tell me that passwords are generally not generated million times (I get that) so performance does not matter (I wouldn't get that).
Thank you for your consideration.