extends TestBase ## Times typing on a long card in Build mode: one key in a result's field on ## the card, in the card's name, and in the inspector's text field. Each number ## is the frame after the key (an idle frame is ~7 ms headless). Not part of ## the suite (the name doesn't start with test_). Run: ## SPREAD=/path/to/spread.json CARD=card_id \ ## godot --headless --path . -s res://tests/perf_typing.gd -- --sample func _init() -> void: if not await start_main(): return main.data.load_json(FileAccess.get_file_as_string(OS.get_environment("SPREAD"))) var t := main.data.get_table(OS.get_environment("CARD")) t.collapsed = false main.set_mode(Main.Mode.BUILD) main._rebuild_cards() await _frames(10) var card: TableCard = main.card_for(t.id) var eid := t.entries[mini(5, t.entries.size() - 1)].id var row_edit: LineEdit = card.edit_ui.text_fields[eid] var name_edit := _first_line_edit(card) row_edit.grab_focus() await _frames(5) var insp_edit: LineEdit = (main.inspector.section_parts[eid]["fields"] as Dictionary)["text"] for field: Array in [["card result", row_edit], ["card name", name_edit], ["inspector text", insp_edit]]: var times: Array[String] = [] for i in 4: var edit: LineEdit = field[1] var started := Time.get_ticks_usec() edit.text += "x" edit.text_changed.emit(edit.text) await process_frame times.append("%.1f" % ((Time.get_ticks_usec() - started) / 1000.0)) print("PERF %s ms per key: %s" % [field[0], ", ".join(times)]) finish() func _first_line_edit(n: Node) -> LineEdit: for c in n.get_children(): if c is LineEdit and (c as LineEdit).editable: return c var found := _first_line_edit(c) if found: return found return null