mirror of
https://github.com/godotengine/godot-benchmarks.git
synced 2025-12-31 09:49:13 +03:00
Allow the benchmark time limit to be changed by individual benchmarks (#73)
This commit is contained in:
committed by
GitHub
parent
6630e6e6c1
commit
331cd6d36c
@@ -1,8 +1,9 @@
|
||||
class_name Benchmark
|
||||
|
||||
|
||||
## Set default benchmark time limit to 5 seconds (5 million microseconds).
|
||||
var benchmark_time := 5e6
|
||||
var test_render_cpu : = false
|
||||
var test_render_gpu : = false
|
||||
var test_idle : = false
|
||||
var test_physics : = false
|
||||
|
||||
|
||||
|
||||
@@ -68,6 +68,7 @@ class TestScene:
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
benchmark_time = 10e6
|
||||
test_physics = true
|
||||
test_idle = true
|
||||
|
||||
|
||||
@@ -58,6 +58,7 @@ class TestScene:
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
benchmark_time = 10e6
|
||||
test_physics = true
|
||||
test_idle = true
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ func _init() -> void:
|
||||
square_mesh.size = Vector2(20.0, 20.0);
|
||||
circle_mesh.radius = 10.0;
|
||||
circle_mesh.height = 20.0;
|
||||
benchmark_time = 10e6
|
||||
test_physics = true
|
||||
test_idle = true
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ var box_mesh := BoxMesh.new()
|
||||
var sphere_mesh := SphereMesh.new()
|
||||
|
||||
func _init() -> void:
|
||||
benchmark_time = 10e6
|
||||
test_physics = true
|
||||
test_idle = true
|
||||
|
||||
|
||||
@@ -165,10 +165,10 @@ func run_test(test_id: TestID) -> void:
|
||||
for i in 3:
|
||||
await get_tree().process_frame
|
||||
|
||||
var time_limit: int = bench_script.get("benchmark_time")
|
||||
begin_time = Time.get_ticks_usec()
|
||||
|
||||
# Time limit of 5 seconds (5 million microseconds).
|
||||
while (Time.get_ticks_usec() - begin_time) < 5e6:
|
||||
while (Time.get_ticks_usec() - begin_time) < time_limit:
|
||||
await get_tree().process_frame
|
||||
|
||||
results.render_cpu += RenderingServer.viewport_get_measured_render_time_cpu(get_tree().root.get_viewport_rid()) + RenderingServer.get_frame_setup_time_cpu()
|
||||
|
||||
Reference in New Issue
Block a user