{"id":20153046,"url":"https://github.com/godotecs/godex_tests","last_synced_at":"2025-03-03T01:21:45.030Z","repository":{"id":53165507,"uuid":"326450212","full_name":"GodotECS/godex_tests","owner":"GodotECS","description":"Test bench for https://github.com/GodotECS/godex","archived":false,"fork":false,"pushed_at":"2021-04-03T06:57:06.000Z","size":27,"stargazers_count":6,"open_issues_count":1,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-01-13T12:20:06.619Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"GDScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/GodotECS.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-01-03T16:26:08.000Z","updated_at":"2023-08-22T15:21:58.000Z","dependencies_parsed_at":"2022-09-14T05:51:57.288Z","dependency_job_id":null,"html_url":"https://github.com/GodotECS/godex_tests","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GodotECS%2Fgodex_tests","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GodotECS%2Fgodex_tests/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GodotECS%2Fgodex_tests/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GodotECS%2Fgodex_tests/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GodotECS","download_url":"https://codeload.github.com/GodotECS/godex_tests/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241592879,"owners_count":19987442,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-13T23:16:44.102Z","updated_at":"2025-03-03T01:21:44.984Z","avatar_url":"https://github.com/GodotECS.png","language":"GDScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Godex bench test\n\nThis repository is used to test the [Godex](https://github.com/GodotECS/godex) performances.\n\n### Compile the bench test\nTo execute this test follow the following instructions.\n\n##### 1. Clone this repository:\n```\ngit clone https://github.com/GodotECS/godex_tests.git \n```\n\n##### 2. Clone the submodules\nThe following commands will clone _Godot_ and _Godex_\n```\ngit submodule update --init --recursive\n```\n\n##### 3. Apply Godex patch at Godot\nFirst go to Godot directory\n```\ncd source/godot/\n```\n\nNow apply the godex patch to Godot\n```\ngit apply ../modules/godex/patches/add_custom_iterator.patch\n```\n\n##### 4. Compile\nGodot is now ready, let's compile it:\n```\n# Linux\nscons p=linuxbsd target=release_debug -j8 custom_modules=../modules\n```\n\n##### 5. Launch Godot editor\nOnce the compilation is done, you can simply launch the Editor with the following command:\n```\n./bin/godot.linuxbsd.opt.tools.64 --path ../../../game -e --single-window\n```\nAt this point, the editor with the test is open and ready.\n\n\n### Testing and considerations.\nThe project is setup to do a direct comparison of `Node` vs `Entities` performances. When you launch the project (by hitting F5 on the editor) `20000` `Nodes` will be added to the scene; half of them are _Debris_ that fly around the center, the other half are squares that are teleported to a random location each frame.\n\nOpen the script `World.gd`, you will have a script like this:\n```gdscript\nfunc _ready():\n\n\t# Spawn ECS entities\n\tvar godex = false\n\t# Element to spawn\n\tvar spawn_count = 10000\n\n\t# The spawned element uses or not use the mesh. \n\tvar no_mesh = false\n\n\t# Want to spawn debris\n\tvar debris = true\n\t# Want to spawn random transform\n\tvar random_transform = true\n\n\tfor i in range(spawn_count):\n\t\tif godex == false:\n\t\t\tif debris:\n\t\t\t\tspawn_node_debris(...)\n\t\t\tif random_transform:\n\t\t\t\tspawn_node_random_transform(...)\n\n\t\telse:\n\t\t\tif debris:\n\t\t\t\tspawn_entity_debris(...)\n\t\t\tif random_transform:\n\t\t\t\tspawn_entity_random_transform(...)\n```\nYou can tweak the above variables to spawn `Entities` instead of `Nodes`, change the amount of elements spawned.\n**Note 1:** The default `spawn_count` number maybe too much or too low for you CPU, so tweak it accordingly.\n**Note 2:** To see the performances, while the game is running, open the `Debugger \u003e Monitors` and check the framerate. _This is really naive, but it's enough for now._\n\n##### Considerations\nThe `Node`s and the `Entities` are doing exactly the same thing, but in different ways (check _modules/test_nodes_and_systems_).\nOn my machine the `Godot Node` scene is running around 40FPS while the `Godex` scene is running at 60FPS (around 1.5 the `Godot Node` scene frame rate). However, this just because the _Rendering_ is a bottleneck.\n\nIf you really want to compare only the `Node` processing and the `Entity` processing, you have to set the parameter `var no_mesh = false` to `true`.\nIn this way will spawn `Node`s / `Entities` without meshes, so the rendering will not run. The performance gain will be order of magnitude more, just give it a check.\nFor example: with `Godex` my machine can handle 1'000'000 `Entities` (no meshes) with a frame rate of 30FPS; while it can handle at max only 220'000 `Nodes` at same frame rate. _Note, this is in single thread and Godex will automatically run this in multiple threads, once the feature is implemented._\n\nAs soon as you start introducing bottlenecks, the performance gain decreases. However, the gameplay code performs all the logic without dealing with rendering, so such part is still optimized anyway. The gameplay systems will be executed automatically in multiple threads, (a thing that can't be achieved with OO scripts) improving even more the performances.\n\nBy reducing the resource cost for the gameplay code, you will be able to increase the amount of data processed; or if you are working on a multiplayer game it's possible to lower the server costs (since, only the gameplay code runs on the server).\n\nAlso, probably, in future the slow parts like the rendering or the physics, will perform their operations with more cache friendly code (or even using ECS [so these would even use multiple threads efficiently]) so the current bottlenecks will be removed and the amount of elements on the screen is increased.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgodotecs%2Fgodex_tests","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgodotecs%2Fgodex_tests","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgodotecs%2Fgodex_tests/lists"}