-
Notifications
You must be signed in to change notification settings - Fork 12
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
Performance #45
Comments
Besides that further optimizations are: Do a simple string cutoff if you roundDown a positive number or roundUp a negative number. |
Indeed this are cool optimization, I need to test it |
The above comment is phishing and it should be removed. |
@TheLevti, after looking at the BC::roundDown method, its approach is more complicated than other cases you mention. The approach are about the
After checking above of these methods, the |
I don't suggest to completely replace it, just for specific cases we should take shortcuts. |
I am not quite sure what you conclude in the last comment :) When you do several thousand BC operations per second, it is heavily noticeable how much CPU is required. Little optimizations showed huge differences. Unfortunately I did not have time to properly contribute to this issue code wise. But if you agree, for sure I can find some time to contribute. |
@TheLevti, thanks for your reply. I concluded that we might use other approaches to refactor the |
Performance implications
I am using
BC::roundDown()
on my responses to always round down specific fields to a specific decimal place. Now let's say we have in a for me realistic scenario of 16000BC::roundDown()
operations on my response. It's fine if they are all raw and not already rounded. But what if they are already? In my case the values coming cache and other sources are already rounded to 2 decimals. So why should I runBC::roundDown()
again, but at the same time I can not be sure that the source always gives me formatted values?I did 3 different solutions with 10 million values to be round:
preg_match
BC::roundDown
as we currently do:Simple validation with explode takes 2.6 seconds to run.
Using preg_match takes 0.8 seconds to run
Just do what we do now and just run BC::roundDown takes 76 seconds to run
So projected on my current project, I can drop another 10 ms at least from the response generation. And in total reduce CPU time if we can add this simple validation to the library where it makes sense.
Code used for the test
The text was updated successfully, but these errors were encountered: