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

pingmessage: performance improvements #110

Merged
merged 5 commits into from Jul 29, 2021
Merged

pingmessage: performance improvements #110

merged 5 commits into from Jul 29, 2021

Conversation

ES-Alexander
Copy link
Contributor

Up to 27% faster for Ping360 on 2M baud serial connection

  • updated calculate_checksum to use built in sum instead of manual loop
  • added __slots__ to PingParser
  • updated parse_byte to directly call the relevant function for the current state
  • added ERROR status code to be in line with ping-cpp

@ES-Alexander
Copy link
Contributor Author

Helps with #101 (although Python's I/O can't really ever be completely as fast as compiled code).

Copy link
Member

@patrickelectric patrickelectric left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks ok to me, I would just recommend to break the commit in multiple commits since there is a couple of things that are changing to improve performance, but they are not totally clear.

An example of commit organization:

  • Change sum algorithm to built-in function
  • Use __slots__ declaration to improve access speed
    • Reason, why, when and etc
  • Break parser logic into a callback dictionary
    • Reason, why and etc
  • Change comparison from is to == since...

ping @Williangalvani

Copy link
Member

@Williangalvani Williangalvani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me!

@patrickelectric patrickelectric merged commit d834eb5 into bluerobotics:master Jul 29, 2021
@patrickelectric
Copy link
Member

:shipit: thanks for the updates!

patrickelectric added a commit to patrickelectric/ping-python-1 that referenced this pull request Nov 30, 2021
This should be zero and not one, the error was introduced in a rework on bluerobotics#110:
https://github.com/bluerobotics/ping-python/pull/110/files#diff-ed2c04d88418d534a1ae078d8a994d08848d370ca71de0d0af5ab5f7b6f19d99R345

Signed-off-by: Patrick José Pereira <patrickelectric@gmail.com>
patrickelectric added a commit that referenced this pull request Nov 30, 2021
This should be zero and not one, the error was introduced in a rework on #110:
https://github.com/bluerobotics/ping-python/pull/110/files#diff-ed2c04d88418d534a1ae078d8a994d08848d370ca71de0d0af5ab5f7b6f19d99R345

Signed-off-by: Patrick José Pereira <patrickelectric@gmail.com>
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.

None yet

3 participants