Skip to content
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

Avoid using % in BigQueueC. #354

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

raidoz
Copy link
Contributor

@raidoz raidoz commented Sep 29, 2015

BigQueueC is faster when % is not used.

@vlahan
Copy link
Member

vlahan commented Sep 29, 2015

Hi Raido,

can you quantify the improvement? On what platform did you notice this to be a significant performance issue? We should be careful not to start changing files only because we don't like the existing style if the benefits from the change are marginal.

--Vlado

@raidoz
Copy link
Contributor Author

raidoz commented Sep 29, 2015

It was an old internal change that I stumbled upon, but if I remember correctly, then the modulus operator started to have a noticeable effect on performance when doing a lot of printf(which uses the queue internally) at high baudrates(like 500000) on an Atmel RFA1. Or rather we were able to print a lot more if we replaced the % operations.

I can also refer to http://embeddedgurus.com/stack-overflow/2011/02/efficient-c-tip-13-use-the-modulus-operator-with-caution/ as a reason to avoid the % in such cases for AVR and MSP. This substitution will probably not have much effect for ARM, but I don't think it will hurt either.

@raidoz
Copy link
Contributor Author

raidoz commented Oct 1, 2015

Changed the if to a while. I would expect the action to normally not run at all or run just once, so should still be better than the %.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants