Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Physics 2D benchmarks #72

Merged
merged 4 commits into from
Jun 14, 2024
Merged

Conversation

OverloadedOrama
Copy link
Contributor

Adds the following benchmarks from #36:

  • 🟥CPU🟥 Area2D : Place 2000 kinematic bodies, move around 1000 Area2D nodes of different chapes. Measure performance for 10 seconds.
  • 🟥CPU🟥 CharacterBody : Make a complex scene (maybe using tilemap). Throw 1000 CharacterBodies running around and jumping randomly.Measure performance for 10 seconds.
  • 🟪Algorithm🟪 RayCast: Measure how much it takes doing 10000 raycasts in a complex scene (lots of shapes). From random pairs of points.

CPU🟥 Rigid Bodies : Throw 2000 shapes next to each other in a pit, let them solve and stack, measure performance for 20 seconds was already implemented in rigid_body_2d.gd.

For the CharacterBody2D benchmark, I used the tileset from the Godot 2D physics platformer demo and made a new scene using it. I'm not sure if it's "complex" enough, so let me know if I should make changes.

For the Raycast2D benchmark, I used PhysicsServer2D instead of creating a scene, as using a scene would use the 5 second timer, and since this is an algorithm, I figured we should use pure code instead. A downside of this approach is that the scene (which has 2000 shapes), is being created via code and thus is being included in the resulting time. Should I create a pre-made scene instead of creating a new one on the fly via code? I'm not sure how I can disable the 5 second timer if I do that though.

As I mentioned here #71 (comment), the timer is hard-coded to 5 seconds, and thus I can't change the time for individual benchmarks to the 10 and 20 seconds that are requested. If this is desired, I could try and refactor the code to allow the amount of seconds to get changed by individual benchmarks in another PR, and I can later update these benchmarks.

Results on my PC

{
"benchmarks": [
{
"category": "Physics > Area 2d",
"name": "1000 Area 2d",
"results": {
"idle": 107.9,
"physics": 18.84,
"time": 0.078
}
},
{
"category": "Physics > Character Body 2d",
"name": "1000 Character Bodies 2d",
"results": {
"idle": 62.01,
"physics": 33.07,
"time": 0.053
}
},
{
"category": "Physics > Raycast 2d",
"name": "10 000 Raycast 2d",
"results": {
"time": 81.67
}
}
],
"engine": {
"version": "v4.3.beta1.official",
"version_hash": "a4f2ea91a1bd18f70a43ff4c1377db49b56bc3f0"
},
"system": {
"cpu_architecture": "x86_64",
"cpu_count": 12,
"cpu_name": "AMD Ryzen 5 1600 Six-Core Processor",
"os": "Linux"
}
}

@Calinou
Copy link
Member

Calinou commented Jun 14, 2024

A downside of this approach is that the scene (which has 2000 shapes), is being created via code and thus is being included in the resulting time.

I think it's fine to measure creation time as well, as we need to make sure it's not too slow (this is frequently done in procedurally generated levels).

As I mentioned here #71 (comment), the timer is hard-coded to 5 seconds, and thus I can't change the time for individual benchmarks to the 10 and 20 seconds that are requested. If this is desired, I could try and refactor the code to allow the amount of seconds to get changed by individual benchmarks in another PR, and I can later update these benchmarks.

Sounds good to me. We can make all physics benchmarks take at least 10 seconds to run but keep other benchmarks to 5, so that running all benchmarks doesn't take too long.

Copy link
Member

@Calinou Calinou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@Calinou Calinou merged commit 85bb12d into godotengine:main Jun 14, 2024
@OverloadedOrama OverloadedOrama deleted the physics branch June 16, 2024 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants