Git Product home page Git Product logo

Comments (4)

nornagon avatar nornagon commented on August 21, 2024

I ran that benchmark on this machine (ubuntu with a crappy gfx driver, but fast cpu and lots of ram) and closure was the clear winner except for rotation (where TDL did better) and transpose (where CanvasMatrix did better).

So if you make this change, be sure to test it very well, since I think it'd be a pretty big drop in readability.

from chipmunk-js.

josephg avatar josephg commented on August 21, 2024

glMatrix doesn't just use arrays. It uses typed arrays (Float32Array).

When I ported cpVect I did some simple benchmarks on jsperf to try and pick the right data structure for vectors - IIRC it wasn't really any faster using arrays. But there's no need to speculate. Hop on jsperf.com and run the experiment.

from chipmunk-js.

josephg avatar josephg commented on August 21, 2024

Oh, and there was a decent (~20% iirc) speedup from making a lot of the 'hot' vectors inline (body.vx, body.vy) instead of body.v.x and body.v.y. They're faster to access and you put less load on the GC. Because javascript is duck typed, you can just pass the body in directly to any of the vector functions.

If we swap to arrays, we lose that little optimization.

from chipmunk-js.

 avatar commented on August 21, 2024

Oh, interesting... in Firefox (x86-64) glMatrix wins and the others yield a lot of 'bad' results, but it stinks in Android Firefox 16-beta (which does support typed arrays). Closure and tdl.fast have a slight edge in Chrome; all three are Google's, surprise surprise. All those matrix libs except glMatrix are 2x-10x faster in Chrome, too. Google's engineers probably figured out how to make regular arrays as fast as typed arrays, just within the past year.

Thanks for the feedback.. glad I asked. I'll close this issue now :)

from chipmunk-js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.