-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
remove if the if condition by assigning function statically #5
Comments
Hey thanks very much for your thoughtful suggestion. I tried the changes and didn't see any material performance gains. However, in testing, I did find a bug! So ultimately I think it was a big win. |
The performance gains will not be visible at the code level. They will be at the energy consumption level of the underlying CPUs, as the if-else branching logic affects the Processor cache pipeline, especially when the processors have branch-prediction logic built-in. If you want to measure the performance at the code level, then try with RDTSC performance counters. |
Interesting. What do you think of this PR? #6 |
Looks fine to me, except for one small thing:
|
Also, It would be great if
|
I got around to implementing this performance fix in #11 and also exposed |
The
crypto
availability is being checked every timerandomBytes
method is called hereThis if else condition checking can be done just once at the beginning, and assign the correct function to a variable, something like below:
This further improves the performance.
The text was updated successfully, but these errors were encountered: