Skip to content

Lots of optimizations#1

Open
forestrf wants to merge 24 commits intoSophieH:masterfrom
forestrf:master
Open

Lots of optimizations#1
forestrf wants to merge 24 commits intoSophieH:masterfrom
forestrf:master

Conversation

@forestrf
Copy link

@forestrf forestrf commented Nov 18, 2018

I have done a lot of optimizations, large and small, without breaking saved mappings and configurations, and with slight API changes that should not require any change to the one using this library.

I have done some testing while working on it, step by step, and I did my best to make sure that there are no bugs, but with so many changes I can't be completely sure.

In build, here is the before and after (about 50% less CPU usage). I think it can be improved further.

Starting point This optimization
2018-11-18_21-35-07 2018-11-18_21-39-35

The scene used for this test is Local Multiplayer with 2 characters (one in a gamepad and the other in keyboard+mouse)

Thank you.

…tedGamepads to a property to prevent external modifications

Merged two variables to a property of type { get; private set; }
…classes that have the same name as those inside SinputSystems. Removed `using SinputSystems;` and manually added `SinputSystems.` to where is needed to prevent conflicts.
…s and comparing hashes. The case of two control names having the same hash is nearly impossible

Some micro optimizations
… checks from ShootyPlayer when checking it doesn't matter
@SophieH
Copy link
Owner

SophieH commented Nov 18, 2018

It will probably take me a while before I can get round to reviewing this properly but a quick scan tells me this is some great work! I'm impressed you managed to figure out so much of the system and improve so much in such a short time! I hope to merge this into the main branch before I get back to work on it :)

Thanks so much!

Bug fix (While searching for the highest axis to use it, a positive axis could override a negative axis of greater magnitude)
Removed axisAsButtonHeld from ControlState as it servers the same purpose as Held in all cases to make the code slightly easier
Small micro optimizations
Optimization: Replaced some Input.GetKey to use a KeyCode instead of a String
@forestrf
Copy link
Author

forestrf commented Nov 19, 2018

So I made another optimization, but this time I only saved 0.05 ms. I found that ButtonHeldCheck is like a downgraded version of AxisCheck, that was already executed, but faster if you only want to check keys instead of axis. But given that we always call AxisCheck and that the button status can be obtained from it, ButtonHeldCheck can be removed.

It is getting difficult. I would like to stabiliza the graph though.

Previous optimization This optimization
2018-11-19_22-37-54 2018-11-19_22-36-17

…hanks to the attribute, but it is useful to be able to initialize it manually too
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