You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: benchmarks/chipmunk.py
+73-23Lines changed: 73 additions & 23 deletions
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,56 @@
1
+
"""
2
+
A suite of benchmarks that tests various simulation setups. Each benchmark is
3
+
designed to stress Pymunk and the underlying Chipmunk2D engine in different
4
+
ways.
5
+
6
+
They meant to measure changes from optimizations made to Pymunk and/or
7
+
Chipmunk, e.g. how did performance change between Pymunk version X and Pymunk
8
+
version Y. The absolute time by itself of a test does not really say that
9
+
much. One test can not be compared to another test.
10
+
11
+
Note that running the full suite of benchmarks is very heavy and
12
+
timeconsuming.
13
+
14
+
Below is an overview of the various benchmarks. These ones were ported over
15
+
from the `box2d-optimized <https://github.com/mtsamis/box2d-optimized>_ fork
16
+
of Box2D, which proposed multuple improvements to the Box2D engine. All credit
17
+
to their creator(s).
18
+
19
+
- Falling squares: A scene with stacked squares of varying sizes falling against a ground body.
20
+
- Falling circles: The same scene as above but with circles.
21
+
- Tumbler: Adds new bodies in each step inside a rotating object (See Tumbler in the Box2D testbed).
22
+
- Add pair: A object that moves very fast hits a big group of resting circles in a zero-gravity world.
23
+
- mild n^2: Spawns a number of composite objects (tables and spaceships as found in one Box2D testbed) one on top of each other, creating a degenerate simulation. Stress test for the broad-phase.
24
+
- n^2: A simpler version of the above. A high number of circles being on top of another, offset only by a small delta, creating an initial 'circle explosion' byu the solver.
25
+
- Multi-fixture: A scene that creates multiple table objects with greatly varying fixture counts.
26
+
- Mostly static (single body): A huge static square made from a high number of small static square fixtures with only very few dynamic bodies that exist in a diagonal corridor inside the big box.
27
+
- Mostly static (multi body): The same scene as above but all the small squares are individual bodies with a single fixture.
28
+
- Diagonal: A benchmark with some dynamic bodies falling through a lot of static bodies that are shaped like diagonal lines. Stress test for contact count.
29
+
- Mixed static/dynamic: A casual scene with both static and dynamic bodies, polygons and circles, some movement and collisions.
30
+
- Big mobile: A structure resembling Box2D's 'balanced mobile' scene but much larger. A lot of joints and bodies.
31
+
- Slow explosion: A 'calm' scene with a high number of bodies moving slowly and without collisions in a zero gravity world.
32
+
33
+
Note that its not possible to directly compare the values to the Box2D
34
+
implementation, unless the simulation state is also reviewed first to match.
35
+
E.g. Pymunk (or Box2D) can be more stable or accurate, which also needs to be
36
+
taken into consideration when comparing the two.
37
+
38
+
..
39
+
It is possible more are added in the future.
40
+
41
+
# Higher is better tests (stability/accuracy) tests
42
+
43
+
- Stack boxes and see how tall until fall down
44
+
- Newtons pendulum
45
+
46
+
# Perf tests
47
+
48
+
- Big body with high velocity hit group of circle in zero gravity. 1000? bodies
49
+
50
+
- Slow explosion
51
+
52
+
"""
53
+
1
54
importargparse
2
55
importcsv
3
56
importgc
@@ -15,21 +68,6 @@
15
68
pymunk.pygame_util.positive_y_is_up=True
16
69
except:
17
70
pass
18
-
"""
19
-
Benchmarks
20
-
21
-
# Higher is better tests (stability/accuracy) tests
22
-
23
-
- Stack boxes and see how tall until fall down
24
-
- Newtons pendulum
25
-
26
-
# Perf tests
27
-
28
-
- Big body with high velocity hit group of circle in zero gravity. 1000? bodies
0 commit comments