Return a table of the most recent N profiled frames with per-frame metrics. Example: u profiler frames -c 30
(
ctx: typer.Context,
count: Annotated[
int,
typer.Option("--count", "-c", help="Number of frames to retrieve"),
] = 10,
json_flag: Annotated[
bool,
typer.Option("--json", help="Output as JSON"),
] = False,
)
| 126 | |
| 127 | @profiler_app.command("frames") |
| 128 | def profiler_frames( |
| 129 | ctx: typer.Context, |
| 130 | count: Annotated[ |
| 131 | int, |
| 132 | typer.Option("--count", "-c", help="Number of frames to retrieve"), |
| 133 | ] = 10, |
| 134 | json_flag: Annotated[ |
| 135 | bool, |
| 136 | typer.Option("--json", help="Output as JSON"), |
| 137 | ] = False, |
| 138 | ) -> None: |
| 139 | """Return a table of the most recent N profiled frames with per-frame metrics. |
| 140 | |
| 141 | Example: |
| 142 | u profiler frames -c 30 |
| 143 | """ |
| 144 | context: CLIContext = ctx.obj |
| 145 | try: |
| 146 | result = context.client.profiler.frames(count=count) |
| 147 | if _should_json(context, json_flag): |
| 148 | print_json(result) |
| 149 | else: |
| 150 | frames = result.get("frames", []) |
| 151 | if not frames: |
| 152 | print_line("[dim]No profiler frames available[/dim]") |
| 153 | return |
| 154 | |
| 155 | title = f"Profiler Frames ({result.get('firstFrameIndex', '?')}-{result.get('lastFrameIndex', '?')})" |
| 156 | headers = ["Frame", "FPS", "CPU (ms)", "GPU (ms)", "Batches", "Draw Calls", "GC Alloc"] |
| 157 | rows = [ |
| 158 | [ |
| 159 | str(f.get("frameIndex", "")), |
| 160 | str(f.get("fps", "-")), |
| 161 | str(f.get("cpuFrameTimeMs", "-")), |
| 162 | str(f.get("gpuFrameTimeMs", "-")), |
| 163 | str(f.get("batches", "-")), |
| 164 | str(f.get("drawCalls", "-")), |
| 165 | str(f.get("gcAllocBytes", "-")), |
| 166 | ] |
| 167 | for f in frames |
| 168 | ] |
| 169 | |
| 170 | if is_no_color(): |
| 171 | _print_plain_table(headers, rows, title) |
| 172 | else: |
| 173 | from rich.table import Table |
| 174 | |
| 175 | table = Table(title=title) |
| 176 | for h in headers: |
| 177 | table.add_column(h, justify="right") |
| 178 | for r in rows: |
| 179 | table.add_row(*r) |
| 180 | get_console().print(table) |
| 181 | except UnityCLIError as e: |
| 182 | _handle_error(e) |
nothing calls this directly
no test coverage detected