Ams.js vs Box2d Benchmarks. strange finding

Discussion and feedback on Construct 2

Post » Sun Feb 15, 2015 2:45 am

Sorry, what I meant was Collision Disabling with asm.js is not supported on Intel XDK yet. :-( I exported my mobile game with Intel XDK build and when I tested APK I was wondering why my game was messed up. My character would freeze and game was unplayable. Took me a good while to figure out that Intel XDK doesn't support collision disabling yet with asm.js so I had to switch back to Box2dweb and everyone was fixed. Gonna have to wait for next update of Intel XDK maybe.
B
20
S
5
G
1
Posts: 102
Reputation: 1,694

Post » Sun Feb 15, 2015 8:51 pm

@delaflaquita - that is super interesting. I wouldn't think that it would matter if you exported on intel xdk. Good to know, because I have been using that as of late.
Image
B
31
S
11
G
2
Posts: 555
Reputation: 5,055

Post » Sun Feb 15, 2015 10:05 pm

In my mini-game it seems that Box 2d does micro-stutters after about 2 minutes adding and destroying objects. Chipmunk on the other hand never seems to get this way. I let the simulation run while i cooked dinner and came back to it preforming as good as when i left it.

Changed back to ASM box 2d and the micro stutters where back.

Think I am going to experement more with this later. I amvery impressed with Chipmunk so far.
B
28
S
8
G
4
Posts: 767
Reputation: 5,950

Post » Sun Feb 15, 2015 11:54 pm

@jojoe , that is good to know. I've noticed the micro-stutters with box2d as well when objects added/destroyed.
B
39
S
19
G
48
Posts: 946
Reputation: 28,987

Post » Mon Feb 16, 2015 1:28 pm

I'd point out that the performance of Box2D physics is significantly determined by the number of velocity and position iterations, which currently default to 8 velocity iterations and 3 position iterations. This is the tradeoff between CPU work and physics accuracy. Comparing it to another physics engine is difficult, because it could use a default equivalent to say 4 & 2 iterations, making it less accurate but less CPU intensive. You can probably turn down the iteration count until Box2D is faster than another engine, but then the accuracy of the physics simulation suffers, and it is probably difficult to compare the accuracy of two different physics engines.

Further the C2 physics engine has features that involve adding callbacks to the physics engine which probably have a small performance impact - disable collisions requires collision callbacks, and the physics engine is also able to fire normal 'On collision' events upon physics collisions (which wouldn't otherwise happen). If another physics engine does not support these features, it has an unfair performance advantage since it does not have to do the same work.

We have a benchmark (based around circle collision shapes, which I think makes the difference) which clearly shows asm.js physics is about 3x faster than box2dweb in that case. So even if in other cases asm.js is about the same, if sometimes it's that much faster, it's definitely worth having.

We aim by the next stable release to have asm.js physics as the default.
Scirra Founder
B
373
S
218
G
84
Posts: 23,440
Reputation: 186,070

Post » Mon Feb 16, 2015 5:46 pm

@jojoe - do you notice those stutters only in asm.js or is it in box2d web as well?

@Ashley - In your benchmarks, do you use gravity? I am just curious. I like box2d over chipmunk, because it seems more stable to me. I used circles bouncing around and added them manually until cpu was where I wanted it. Now that you mentioned iterations, that is definitely something to consider. chipmunk handled more circles in the test but the physics simulation brokedown (I was losing energy in the spheres over time which isn't right).
Image
B
31
S
11
G
2
Posts: 555
Reputation: 5,055

Post » Mon Feb 16, 2015 7:05 pm

Yes, it was just a big bucket which I filled with circle collision sprites (with gravity so they all fall down). A clear 3x difference in the object count, far higher with asm.js physics. Which makes sense since it's practically a native compilation anyway.
Scirra Founder
B
373
S
218
G
84
Posts: 23,440
Reputation: 186,070

Post » Mon Feb 16, 2015 7:46 pm

@ruskul

It was Box2D, with and without asm.

I was testing with NodeWebkit (nw.js) too if that makes any difference.
B
28
S
8
G
4
Posts: 767
Reputation: 5,950

Post » Thu Feb 19, 2015 5:23 pm

@ruskul Have you set friction to 0 and also built a frame with 0 friction around? It is normal to lose energy when there's friction between objects
B
11
S
3
G
1
Posts: 91
Reputation: 997

Post » Thu Feb 19, 2015 8:15 pm

@BouncyTrip - yeah, Friction was all set to 0 in both box2d and chipmunk. Thanks though, that's important. That's a pretty sweet hat.
Image
B
31
S
11
G
2
Posts: 555
Reputation: 5,055

PreviousNext

Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 8 guests