Pular para o conteúdo

Analisador de Profiler

Grave com o profiler nativo do FiveM, solte o JSON salvo aqui e receba um relatório legível: tempo por resource, piores frames, threads e eventos mais pesados, picos ao longo do tempo e dicas diretas do que corrigir. Tudo é processado no seu navegador, nada é enviado.

Por enquanto, esta ferramenta e as notas dela estão em inglês.

ServidorDesempenho, ResmonLer a documentação

How to record a profile

FiveM has a profiler built in on both sides. It records every resource tick and event handler with microsecond timing, including escrowed resources, and saves it as a Chrome trace file.

Server (txAdmin Live Console or the FXServer window)

profiler record 1200
profiler status
profiler saveJSON lag.json

The server runs 20 ticks per second, so 1200 ticks is one minute. Record during peak hours: problems that only show with players online will not show on an empty server. The file is written to the folder FXServer runs in (next to server.cfg with txAdmin).

Client (F8 console)

profiler record 1000
profiler saveJSON lag.json

Stand where the game feels bad and do the laggy thing while it records. The file ends up in%localappdata%\FiveM\FiveM.app\citizen\. Client recordings store a small screenshot per frame, which is why they get big. Files of a few hundred MB are fine here.

Other profiler commands

  • profiler record start and profiler record stop: record until you stop it.
  • profiler resource myresource 300: records Lua function calls of one resource (use * for all). Slower, but shows which function is heavy.
  • profiler view: opens the raw trace in Chrome DevTools, handy for a manual look.
  • profiler save name writes a binary file this page can't read. Use saveJSON.

What you are looking at

Script time vs frame time

Script time is what resources spent in a frame (client) or tick (server): their threads, event handlers and callbacks. Frame time on the client is the time between two frames for the whole game, and tick interval on the server is the time between two server ticks. When the gap is big but script time is small, the stall came from somewhere else (streaming, the host, garbage collection in C# or JS), and the findings say so instead of blaming a script.

Budgets

ClientServer
Frame or tick16.7 ms at 60 FPS50 ms (20 ticks per second)
Scripts get heavy at4 ms per frame25 ms per tick
Hitcha frame over 50 msticks over 150 ms apart (the console's hitch warning)
One resource worth a look0.1 ms per frame, heavy from 0.5 ms0.5 ms per tick, heavy from 2 ms

Resources

Avg is time per frame or tick over the whole recording, the same thing resmon shows. Times are exclusive: when resource A triggers an event in resource B, B's handler counts for B, not twice. Click a resource to see what triggered it (its tick or which events), its Lua threads and handlers with file and line numbers, and its worst frames. It also lights up in white on the timeline.

Timeline and frames

One bar per frame or tick. Amber and red mark the budgets above. Click a bar to open that frame: a flame chart of exactly what ran, in order, and on the client the screenshot the game took at that moment.

Flame graph

The whole recording merged by call path: the wider a block, the more total time it took. Click to zoom in, search to highlight a resource or file.

Findings

Rules that read the numbers: loops that run every frame (the Wait(0) pattern), heavy event handlers, events fired too often, heavy NUI callbacks, spikes that repeat on a timer, resources with many small threads, and hitches with and without a script to blame. Each one shows the evidence and a concrete fix.

Compare

Record before and after a change, open the first file, then drop the second one in Compare. Numbers are per frame or tick, so two recordings of different length still line up.

Privacy

The file never leaves your browser. There is no upload and no shared leaderboard. Resource names in your profile stay on your machine.

Limits

  • Only Lua threads and handlers get names. JS and C# resources show up as a total per resource.
  • The profiler adds a little overhead itself, so absolute numbers run slightly high. Compare recordings made the same way.
  • The "Try a sample" file is made up, with invented resource names.

Sources and other tools