e48d4bbe88
- Introduced a new benchmark save script to create a stress test scenario with extreme values for simulation performance. - Added a full UI benchmark script to measure frame rates and performance metrics during UI interactions. - Implemented tests for coarse generations to ensure population transitions are handled correctly. - Created tests for extra parameters to validate the loading and application of configuration settings. - Developed simulation optimization tests to verify the efficiency of population drift and rounding mechanisms. - Added split optimization tests to ensure accurate allocation and rounding behavior in population management. - Included startup parameter tests to confirm the correct initialization of global parameters before scene readiness. - Enhanced the audit rounding ledger to compare selective and full rounding results for consistency.
49 lines
2.7 KiB
GDScript
49 lines
2.7 KiB
GDScript
extends SceneTree
|
|
const E = preload("res://world/owniverse/math/exact.gd")
|
|
func _initialize(): call_deferred("run")
|
|
func restore(value):
|
|
if value is float and value == floorf(value) and absf(value) <= 9007199254740991: return int(value)
|
|
if value is Dictionary:
|
|
for k in value: value[k] = restore(value[k])
|
|
elif value is Array:
|
|
for i in value.size(): value[i] = restore(value[i])
|
|
return value
|
|
func run():
|
|
var payload = E.decode(restore(JSON.parse_string(FileAccess.get_file_as_string("res://tests/artifacts/all_objects_speed6.adventure.json"))))
|
|
var scene = load("res://world/world.tscn").instantiate()
|
|
var stage = scene.get_node("Stage")
|
|
stage.owniverse.free()
|
|
stage.set_script(load("res://tests/fixtures/benchmark_ui_stage.gd"))
|
|
root.add_child(scene)
|
|
await process_frame
|
|
stage.owniverse.state = payload.state.duplicate(true)
|
|
stage.owniverse.restore_frame_checkpoint(payload.get("simulation", {}))
|
|
stage.owniverse.presentation.refresh(stage.owniverse.state, stage.owniverse.catalog)
|
|
stage.set_owniverse_item_value()
|
|
stage.stage_page_scroller.scroll_horizontal = 4 * stage.PAGE_WIDTH
|
|
var initial_requested: Variant = stage.owniverse.frame_clock.get("datetime", stage.owniverse.state.time.datetime)
|
|
var initial_published: Variant = stage.owniverse.state.time.datetime
|
|
stage.owniverse.profile_enabled = true
|
|
stage.measuring = true
|
|
for i in 600: await process_frame
|
|
stage.measuring = false
|
|
var samples = stage.frame_samples
|
|
var total: float = 0
|
|
for sample in samples: total += sample
|
|
samples.sort()
|
|
print("Saved UI: FPS=%.2f mean=%.2fms p95=%.2fms max=%.2fms commits=%d" % [1000.0/(total/samples.size()),total/samples.size(),samples[int(ceil(samples.size()*0.95))-1],samples.back(),stage.owniverse.frame_commits])
|
|
var requested_advance: Variant = E.subtract(stage.owniverse.frame_clock.datetime, initial_requested)
|
|
var published_advance: Variant = E.subtract(stage.owniverse.state.time.datetime, initial_published)
|
|
print("Requested years advanced=", requested_advance, " published=", published_advance, " throughput=", E.divide(published_advance, requested_advance))
|
|
print("UI CPU profile: ", stage.owniverse.profile)
|
|
var remaining_objects: int = 0
|
|
for id in stage.owniverse.catalog.entities:
|
|
if E.gt(stage.owniverse.ledger.physical_amount(stage.owniverse.state, id), 0): remaining_objects += 1
|
|
print("Remaining objects: ", remaining_objects)
|
|
print("Final adaptive step: ", stage.owniverse.frame_step_seconds)
|
|
for entity in stage.owniverse.catalog.entities.values(): entity.free()
|
|
stage.owniverse.free()
|
|
scene.free()
|
|
for i in 3: await process_frame
|
|
quit()
|