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

Performance improvements #16

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

Conversation

FabianTerhorst
Copy link
Owner

@FabianTerhorst FabianTerhorst commented Nov 4, 2018

Instead of calculating the deltaX, deltaY and r for each item n*n times, it now calculates them n times. Also reduced the allocations by caching the transformed polymer instead of allocating it inside each interaction check.

@FabianTerhorst
Copy link
Owner Author

This is fixing #10 as well.

@FabianTerhorst
Copy link
Owner Author

FabianTerhorst commented Nov 5, 2018

TODO:

  • it should be possible to cache the distance from each path to the observer to calculate that n times instead of n * n times as well
    Tested it: too much to cache not worth it.

@slvrfn
Copy link
Contributor

slvrfn commented Nov 5, 2018

@FabianTerhorst Check out some of the recent branches i made in my fork of the repository, I tried out a few performance improvements that didn't end up being improvements. I found Java to be faster/better at allocating many small objects that eventually get garbage collected instead of performing object pooling.

@FabianTerhorst
Copy link
Owner Author

FabianTerhorst commented Nov 6, 2018

What im doing there isn't the same its just calculating the values in the loop before the intersection check happens n * n times. Its not caching any values accross multiple measurements. Colors are also very easy to calculate thats why i inlined the full logic there so that its getting full java jit optimization.

@FabianTerhorst
Copy link
Owner Author

FabianTerhorst commented Nov 6, 2018

I added a few more raycast algorithms for testing the performance differences. Currently i would prefer the new one 4b0b326#diff-7798cc0d3e9fcdd35a27e8e0f6febf5dR85 .

@slvrfn
Copy link
Contributor

slvrfn commented Nov 6, 2018

Here is a place i was trying to improve but am having trouble with:
image

I have been doing some profiling of the library, and i found the Paint object instantiation is about 75% of the Item creation. If we can reuse the paint objects, we can save a bunch of time here.

@FabianTerhorst
Copy link
Owner Author

have you tried caching the paint object with the associated color integer that got calculated from android.graphics.Color.argb?

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

Successfully merging this pull request may close these issues.

2 participants