Skip to content

Commit c8f9694

Browse files
committed
[bench] n_iter
1 parent 071981f commit c8f9694

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

benchmark/bench_phyjax2d.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ def ball_fall_phyjax2d(
2424
gravity=(0.0, -900.0),
2525
dt=0.002,
2626
viscous_damping=0.6,
27-
n_velocity_iter=10,
27+
n_velocity_iter=4,
2828
n_position_iter=1,
2929
bias_factor=0.1,
3030
bounce_threshold=4,
31-
allowed_penetration=0.01,
31+
allowed_penetration=0.1,
3232
)
3333

3434
for _ in range(n_balls):
@@ -111,12 +111,17 @@ def n_step_fixed(sd, vs):
111111
def main(
112112
counts: list[int] = DEFAULT_COUNTS,
113113
debug_vis: bool = False,
114+
n_iter: int = 1000,
114115
filename: Path = Path("bench.csv"),
115116
) -> None:
116117
results = []
117118

118119
for count in counts:
119-
duration = ball_fall_phyjax2d(count, debug_vis)
120+
duration = ball_fall_phyjax2d(
121+
count,
122+
debug_vis,
123+
n_iter=n_iter,
124+
)
120125
# Convert timedelta to total seconds as a float for the CSV
121126
seconds = duration.total_seconds()
122127
results.append((count, seconds))

benchmark/bench_pymunk.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,15 @@
99
import typer
1010

1111

12-
def ball_fall(n_balls: int, debug_vis: bool, n_iter: int = 1000) -> timedelta:
12+
def ball_fall(
13+
n_balls: int,
14+
debug_vis: bool,
15+
n_iter: int = 1000,
16+
) -> timedelta:
1317
space = pymunk.Space()
1418
# 1. Flip Gravity: Positive Y pulls "down" in PyGame coordinates
1519
space.gravity = (0, 900)
16-
space.iterations = 10
20+
space.iterations = 4
1721

1822
static_body = space.static_body
1923
# 2. Invert Container: Floor is now at Y=800, walls go up toward Y=50
@@ -79,12 +83,18 @@ def ball_fall(n_balls: int, debug_vis: bool, n_iter: int = 1000) -> timedelta:
7983
def main(
8084
counts: list[int] = DEFAULT_COUNTS,
8185
debug_vis: bool = False,
86+
n_iter: int = 1000,
87+
freefall: bool = False,
8288
filename: Path = Path("bench.csv"),
8389
) -> None:
8490
results = []
8591

8692
for count in counts:
87-
duration = ball_fall(count, debug_vis)
93+
duration = ball_fall(
94+
count,
95+
debug_vis,
96+
n_iter=n_iter,
97+
)
8898
# Convert timedelta to total seconds as a float for the CSV
8999
seconds = duration.total_seconds()
90100
results.append((count, seconds))

0 commit comments

Comments
 (0)