Physics engine benchmark ideas.

Sage
Posts: 1,482
Joined: 2002.09
Post: #1
Usually when doing performance testing on Chipmunk I just run time trials of whatever random demos I currently have in my demo application. For years I've thought that I really should make some proper benchmarking scenes, but have never really gotten around to it. Yesterday I finally started. So far I have these:

Lots of circles or boxes interacting with a simple rough static terrain (48 line segments):
[Image: upshot_GjtDFXm5.png]
Tested with constant sized circles, 1000, 500, and 100 count.
Tested with constant sized boxes, 1000, 500, and 100 count.
Tested with variable sized circles, 500 count.
Tested with variable sized boxes, 500 count.

The idea here is mostly to test the speed of the solver and general collision detection algorithms. Objects quickly settle to their final places and don't move much afterwards.


1000 frictionless circles interacting with a complex static terrain (262 line segments):
[Image: upshot_uYS8cuoW.png]Similar to the first benchmark, but encouraging objects to move more. The balls fall into the basin and fill the tunnels.


500 perfectly elastic circles interacting with a complex, high resolution, static terrain (516 line segments):
[Image: upshot_GUMeCMxZ.png]
Stress test the collision detection with moving objects. With no persistent contacts, the solver should take up very little of the CPU time.


28 moving circles moving through a grid of 825:
[Image: upshot_8rpUojBr.png]
The moving circles bounce off the edges of the screen, but otherwise collisions never occur. More stress testing of the collision detection, but this time making sure that it's good at filtering out false positives.


Does anybody have other ideas of common physics usage that should be benchmarked? Also, anybody know what to use in place of gettimeofday() on Windows?.

Scott Lembcke - Howling Moon Software
Author of Chipmunk Physics - A fast and simple rigid body physics library in C.
Quote this message in a reply
Moderator
Posts: 3,579
Joined: 2003.06
Post: #2
(Feb 24, 2011 02:20 PM)Skorche Wrote:  Also, anybody know what to use in place of gettimeofday() on Windows?.

You could try something like this (I don't recall if I have actually tested/used it yet, but it's in my codebase, so maybe it works?):

Code:
double GetTimeForWindows(void)
{
    static LARGE_INTEGER frequency;
    LARGE_INTEGER currentTime;

    if (frequency.QuadPart == 0)
    {
        QueryPerformanceFrequency(&frequency);
    }
    QueryPerformanceCounter(&currentTime);

    return (double)currentTime.QuadPart / frequency.QuadPart;
}
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #3
BTW, gettimeofday isn't best for either Mac or Linux, though it at least works on both. mach_absolute_time for Mac, and... uh... ask ThemsAllTook for Linux XD
Quote this message in a reply
Moderator
Posts: 3,579
Joined: 2003.06
Post: #4
I think it's clock_gettime() for Linux.
Quote this message in a reply
Sage
Posts: 1,482
Joined: 2002.09
Post: #5
Oh? gettimeofday() seems to be pretty accurate to the sub-millisecond level. I guess I'll have to write an #ifdef for the time function anyway. Might as well use mach time.

Scott Lembcke - Howling Moon Software
Author of Chipmunk Physics - A fast and simple rigid body physics library in C.
Quote this message in a reply
Moderator
Posts: 3,579
Joined: 2003.06
Post: #6
It's plenty accurate, but gettimeofday isn't monotonic on the Mac since it is based on "wall clock" time, which can be updated/changed automatically, when you don't expect it to. I got slapped for this and use mach time now instead.
I just remembered ThemsAllTook posted his cross-platform time func not too long ago, here, which looks pretty good (in fact, that looks like where I got my Windows function I posted above).
Quote this message in a reply
Sage
Posts: 1,482
Joined: 2002.09
Post: #7
To anybody that's interested in a Box2D performance comparison.

I'm pretty happy with that. Smile I guess all that time I spent optimizing the solver and collision detection paid off.

Scott Lembcke - Howling Moon Software
Author of Chipmunk Physics - A fast and simple rigid body physics library in C.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  2D Physics Engine Philosophy Shunter 11 8,309 Jun 11, 2009 09:33 PM
Last Post: Shunter
  General Physics Engine Questions wyrmmage 1 2,968 Feb 7, 2008 06:27 PM
Last Post: wyrmmage
  Bullet Physics Library / COLLADA physics viewer erwincoumans 14 12,955 Aug 12, 2006 12:59 AM
Last Post: Fenris