Return metrics for the latest profiled frame (FPS, CPU/GPU ms, draw calls, GC allocs).
(
ctx: typer.Context,
json_flag: Annotated[
bool,
typer.Option("--json", help="Output as JSON"),
] = False,
)
| 80 | |
| 81 | @profiler_app.command("snapshot") |
| 82 | def profiler_snapshot( |
| 83 | ctx: typer.Context, |
| 84 | json_flag: Annotated[ |
| 85 | bool, |
| 86 | typer.Option("--json", help="Output as JSON"), |
| 87 | ] = False, |
| 88 | ) -> None: |
| 89 | """Return metrics for the latest profiled frame (FPS, CPU/GPU ms, draw calls, GC allocs).""" |
| 90 | context: CLIContext = ctx.obj |
| 91 | try: |
| 92 | result = context.client.profiler.snapshot() |
| 93 | if _should_json(context, json_flag): |
| 94 | print_json(result) |
| 95 | else: |
| 96 | display_keys = [ |
| 97 | ("fps", "FPS"), |
| 98 | ("cpuFrameTimeMs", "CPU Frame Time"), |
| 99 | ("cpuRenderThreadTimeMs", "CPU Render Thread"), |
| 100 | ("gpuFrameTimeMs", "GPU Frame Time"), |
| 101 | ("batches", "Batches"), |
| 102 | ("drawCalls", "Draw Calls"), |
| 103 | ("triangles", "Triangles"), |
| 104 | ("vertices", "Vertices"), |
| 105 | ("setPassCalls", "SetPass Calls"), |
| 106 | ("gcAllocCount", "GC Alloc Count"), |
| 107 | ("gcAllocBytes", "GC Alloc Bytes"), |
| 108 | ] |
| 109 | |
| 110 | rows = [[label, str(result.get(key))] for key, label in display_keys if result.get(key) is not None] |
| 111 | |
| 112 | if is_no_color(): |
| 113 | _print_plain_table(["Metric", "Value"], rows, f"Frame {result.get('frameIndex', '?')}") |
| 114 | else: |
| 115 | from rich.table import Table |
| 116 | |
| 117 | table = Table(title=f"Frame {result.get('frameIndex', '?')}") |
| 118 | table.add_column("Metric") |
| 119 | table.add_column("Value", justify="right") |
| 120 | for r in rows: |
| 121 | table.add_row(*r) |
| 122 | get_console().print(table) |
| 123 | except UnityCLIError as e: |
| 124 | _handle_error(e) |
| 125 | |
| 126 | |
| 127 | @profiler_app.command("frames") |
nothing calls this directly
no test coverage detected