Cost of a hook's functions
perf_hook_costMeasures per-function time spent during a Garry's Mod hook event over a chosen duration, reporting calls, total/avg/max ms, and source lines sorted by cost.
Instructions
Measures over duration_s the time spent in each function of a hook event: every hook.Add function registered when it starts, and GAMEMODE:. Each one is wrapped with a timer for the measurement and put back afterwards (restored = how many hooks were put back; a hook replaced meanwhile is left alone). Waits the whole duration. Result: {event, duration_s, functions: [{id, calls, total_ms, avg_ms, max_ms, src {source, line}}] sorted by total_ms, most expensive first, restored}. The game runs at its real frame rate: on a light test client (20 fps) the number of calls is lower than in a normal game. Example: {"realm": "client", "event": "Think", "duration_s": 10} (event is required; the length is duration_s, not seconds).
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"event": "<event>"
},
"name": "perf_hook_cost"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| event | Yes | Hook event name, e.g. 'Think', 'Tick', 'PlayerTick'. | |
| realm | No | Default server. | |
| instance | No | Optional. Instance identifier (see instances_list). If present and different from the local instance, the call is relayed by the coordinator to that instance. | |
| duration_s | No | Measurement length in seconds (default 5). |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| next | No | ||
| note | No | ||
| event | Yes | ||
| warning | No | ||
| restored | No | ||
| functions | Yes | ||
| next_call | No | ||
| duration_s | No | ||
| answered_by | No | ||
| truncated_note | No | ||
| version_warning | No |