89 lines
4.8 KiB
GDScript
89 lines
4.8 KiB
GDScript
extends RefCounted
|
|
var failures=0
|
|
var records=[]
|
|
func check(ok,label):
|
|
if not ok:failures+=1;push_error("MAIDEN PERFORMANCE QA: "+label)
|
|
func sample(g,label,frames=120):
|
|
var times=[]
|
|
var life_cost=Vector3.ZERO
|
|
g.set_meta("profile_life",true)
|
|
for frame in range(frames+30):
|
|
g.workshop.spawn_clock=-100.0
|
|
var start=Time.get_ticks_usec()
|
|
await g.get_tree().process_frame
|
|
await RenderingServer.frame_post_draw
|
|
if frame>=30:
|
|
times.append(float(Time.get_ticks_usec()-start)/1000.0)
|
|
life_cost+=g.get_meta("life_profile",Vector3.ZERO)
|
|
times.sort()
|
|
var record={"phase":label,"median_ms":times[times.size()/2],"p95_ms":times[int(times.size()*.95)],
|
|
"process_ms":Performance.get_monitor(Performance.TIME_PROCESS)*1000,
|
|
"physics_ms":Performance.get_monitor(Performance.TIME_PHYSICS_PROCESS)*1000,
|
|
"nodes":Performance.get_monitor(Performance.OBJECT_NODE_COUNT),
|
|
"objects":Performance.get_monitor(Performance.OBJECT_COUNT),
|
|
"draws":Performance.get_monitor(Performance.RENDER_TOTAL_DRAW_CALLS_IN_FRAME),
|
|
"primitives":Performance.get_monitor(Performance.RENDER_TOTAL_PRIMITIVES_IN_FRAME),
|
|
"video_mb":Performance.get_monitor(Performance.RENDER_VIDEO_MEM_USED)/1048576.0,
|
|
"burns":g.life.burns.size(),"heat":g.workshop.stations[0].motion.heat if not g.workshop.stations.is_empty() else 0.0,
|
|
"imp_activity_ms":life_cost.x/frames/1000,"imp_movement_ms":life_cost.y/frames/1000,"imp_gait_ms":life_cost.z/frames/1000}
|
|
records.append(record);print("MAIDEN_PROFILE ",JSON.stringify(record))
|
|
return record
|
|
func run(g):
|
|
await g.get_tree().create_timer(.3).timeout
|
|
g.start_game();g.reset_shift();g.game_started=true;g.paused=false;g.menu.show_page("")
|
|
DisplayServer.window_set_vsync_mode(DisplayServer.VSYNC_DISABLED);Engine.max_fps=0
|
|
var w=g.workshop;g.player.position=Vector3(1,0,2);g.camera.size=17
|
|
await sample(g,"empty_room")
|
|
var started=Time.get_ticks_usec();var d=w.add_station(3,Vector3(3,0,0))
|
|
w.rebuild_nav()
|
|
print("MAIDEN_BUILD_MS ",float(Time.get_ticks_usec()-started)/1000.0)
|
|
for mesh in d.device.find_children("*","MeshInstance3D",true,false):
|
|
var triangles=0
|
|
for surface in range(mesh.mesh.get_surface_count()):
|
|
var arrays=mesh.mesh.surface_get_arrays(surface)
|
|
var indices=arrays[Mesh.ARRAY_INDEX]
|
|
triangles+=(indices.size() if indices!=null and indices.size()>0 else arrays[Mesh.ARRAY_VERTEX].size())/3
|
|
print("MAIDEN_GEOMETRY ",mesh.get_parent().name,"/",mesh.name," triangles=",triangles)
|
|
g.player.position=w.approach(d);g.avatar.reset_gait()
|
|
var baseline=await sample(g,"maiden_idle")
|
|
var station_nodes=d.device.find_children("*","",true,false).size()
|
|
for cycle in range(3):
|
|
w.spawn();var soul=g.souls.back();soul.required=[3];soul.entering=false;soul.entry_time=1
|
|
g.set_soul_reveal(soul.visual,1);w.attach(soul,0)
|
|
var root=soul.node;var target=g.done+1
|
|
for step in range(24):
|
|
w.step_station(d,.1,true)
|
|
await g.get_tree().process_frame
|
|
if cycle==0:await sample(g,"maiden_hot",45)
|
|
for step in range(60):
|
|
if d.soul<0:break
|
|
w.step_station(d,.1,true)
|
|
await g.get_tree().process_frame
|
|
check(g.done==target and d.soul<0,"cycle completes once")
|
|
# Cleanup must run through the normal game process, including life.update.
|
|
w.spawn_clock=-100.0
|
|
await g.get_tree().create_timer(6.5).timeout
|
|
check(not is_instance_valid(root) and g.life.burns.is_empty(),"normal frames remove soul and burn effects")
|
|
var cooled=await sample(g,"cooled_%d"%cycle)
|
|
check(d.motion.heat<.001 and d.motion.heat_light.light_energy<.001,"heat and light return to idle")
|
|
check(d.device.find_children("*","",true,false).size()==station_nodes and g.souls.is_empty(),"no accumulating station nodes or souls after repeated cycles")
|
|
# Timings are diagnostic: imp activities and thermal clocks change over time.
|
|
check(cooled.video_mb<baseline.video_mb+8,"video memory returns near idle baseline after cleanup")
|
|
var local_imps=g.life.imps;var neighbours=g.life.neighbours
|
|
g.life.imps=[];g.life.neighbours=[]
|
|
await sample(g,"after_cycles_frozen_imps")
|
|
g.life.imps=local_imps;g.life.neighbours=neighbours
|
|
for x in [6.0,9.0,0.0]:
|
|
started=Time.get_ticks_usec();w.add_station(3,Vector3(x,0,-2))
|
|
print("MAIDEN_REPEAT_BUILD_MS ",float(Time.get_ticks_usec()-started)/1000.0)
|
|
w.rebuild_nav()
|
|
await sample(g,"four_maidens_idle")
|
|
DirAccess.make_dir_recursive_absolute("res://captures/maiden-performance")
|
|
var tag="current"
|
|
for arg in OS.get_cmdline_user_args():
|
|
if arg.begins_with("--maiden-profile="):tag=arg.get_slice("=",1).validate_filename()
|
|
var file=FileAccess.open("res://captures/maiden-performance/"+tag+".json",FileAccess.WRITE)
|
|
file.store_string(JSON.stringify(records,"\t"));file.close()
|
|
print("MAIDEN PERFORMANCE QA ","PASSED" if failures==0 else "FAILED",": rendered timings, repeated cycles, normal-loop cleanup and stable station resources")
|
|
g.get_tree().quit(1 if failures else 0)
|