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

Speedup Matrix inverse #8938

Merged
merged 2 commits into from
May 20, 2016
Merged

Speedup Matrix inverse #8938

merged 2 commits into from
May 20, 2016

Conversation

Corey-Maler
Copy link
Contributor

Remove function call gives up to 30% of speedup. See comparison https://jsfiddle.net/xqs0st3c/

@bhouston
Copy link
Contributor

Nice.

@mrdoob
Copy link
Owner

mrdoob commented May 20, 2016

Should we do the same with Matrix4.getInverse()?

@Corey-Maler
Copy link
Contributor Author

Corey-Maler commented May 20, 2016

Ow, I didn't expect a much speed up in Matrix4, but tests (https://jsfiddle.net/xqs0st3c/1/) shows that in Matrix4 it is even faster (on my computer 1500ms vs 1000ms thats ~35%).

P.S. In google chrome on Mac OS.

But code is little ugly now here.

@mrdoob mrdoob merged commit e803bbc into mrdoob:dev May 20, 2016
@mrdoob
Copy link
Owner

mrdoob commented May 20, 2016

Thanks!

@Usnul
Copy link
Contributor

Usnul commented Jun 14, 2016

for those that are curious why this happens. There are 2 read passes over elements array in the original implementation (one in main body of getInverse and one in multiplyScalar), also if you do an "instanceof" check instead of "elements.length === 9" you get numbers more like these:

Matrix3 test
 T…E.Matrix3 {elements: Float32Array[9]}
old: 438.133ms
new: 347.131ms

which is more like a 20% saving and not 30, still super useful though :)

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.

4 participants