c-frame / aframe-physics-system

community-maintained fork of n5ro's aframe-physics-system
https://c-frame.github.io/aframe-physics-system/
MIT License
43 stars 11 forks source link

Quantify perf difference between Cannon and Ammo #13

Open diarmidmackenzie opened 2 years ago

diarmidmackenzie commented 2 years ago

We have a perf test that has been used to compare Ammo vs. PhysX https://c-frame.github.io/physx/examples/pinboard/ammo-vs-physx.html

This depends on some minor updates to aframe-physics-system to report timing data, which aren't in this fork yet.

We should:

diarmidmackenzie commented 2 years ago

See PR#14

Current data on my PC is showing:

As documented in #15 , we can shave ~1.5msecs off Ammo, which would bring it to ~3.7msecs.

That would give us a position where Ammo = ~2x PhysX and Cannon = ~2x Ammo.

This is just one benchmark, tested on just one device, and we may find that different tests & different devices reveal different performance characteristics.

kylebakerio commented 2 years ago

image

This is what I'm getting on that demo page, fwiw. It keeps fluctuating significantly, though--are the same number of balls generated per-measurement-period ?

kylebakerio commented 2 years ago

I also find watching the subtle behavior difference between the two interesting.

image

You can see on the left that the physx engine is more prone to have balls get 'stuck' on this simulation, like they have more friction almost? Constantly happening on left, buildup is less and less often on the right:

image

It does feel like it's more realistic to my eye right now.

Also, though, sometimes the newly added balls 'bounce up' as well on the physX side--they seem to do this because those 'back ups' happen at the top of the board, and so the new ball is dropped on top of an existing ball that has pushback. Doesn't seem like desired behavior.

It's interesting that Cannon behaves seems to also exhibit the same behavior as PhysX, as opposed to ammo--clumps and clumps at tops causing jumps.

On my laptop, PhysX is 3x faster than Ammo, and 6.5x faster than cannon.

Anyways, I digress, I just enjoy performance testing.

diarmidmackenzie commented 2 years ago

Quite likely that the different engines have different default materials, masses etc

I didn't modify anything away from the defaults, except to set restitution to 0 on cannon, as the default restitution of 0.3 was way too bouncy.

All the engines offer various ways of configuring friction etc. I expect work can be done to compare settings and get them better aligned with each other.

Some differences may be down to the engine itself, of course.