Lag Meter

Updated 8 minutes ago

Join our Discord: discord.gg/haSwxPa9GU to report bugs, request features or other mods, or give feedback.


← All mods in World and Performance

Lag Meter

Switch: F1 → 0 - Sub-mods → Lag Meter (off by default).

A diagnostic tool for finding out why the frame rate drops, so a fix can aim at the real cause. It writes to the BepInEx log (BepInEx/LogOutput.log) and to a data file (BepInEx/LagMeter/, one line per second).

What it measures, every frame

  • Every engine system on the main thread (about 140): scripts, physics (and how many physics steps a frame needs), animation, particles, UI, rendering preparation, loading, waiting for the graphics card or the frame cap.
  • Unity's own counters: main thread, render thread and graphics card time per frame, draw calls, material switches, triangles, shadow casters, animated meshes and memory. So it can tell whether the processor or the graphics card holds the frame back.
  • Scripts by name: Valheim's update batches (creatures, AI, ships, smoke, lights, ground, ...), heavy game systems (object streaming, zones, network, map, camera, building wear, ...), every mod's own updates (labelled with the mod) and, in deep mode, every game component type around you. Calls per frame are counted too.
  • What is around: biome, weather, dungeon or ship, open windows, building pieces nearby, creatures, AIs, loaded objects, lights and shadow lights, particles, moving physics bodies, smoke.

Reports

  • [LowFPS] as soon as a second drops below the threshold (40 by default), again every 10 seconds while it lasts, and an end line. It says what held the frame back (processor or graphics card), which systems and scripts took the time, and what was unusual compared with this session's good seconds (e.g. "shadow casters 14000 (usual 3000)").
  • [Spike] for single frames slower than 100 ms, with that frame's own breakdown.
  • [Lag] every 10 seconds, [Summary] every 5 minutes (time at 40+ fps, slow and good seconds compared).
  • Mark key (F9): press it when something feels laggy, for a [Mark] report of the last 10 seconds.
  • Once per world the saved objects by type ([Census]), every minute the most common loaded objects and what the lights belong to ([Loaded]), and every save a [Save] report.

Notes

  • Client-side and off by default (switch it on in F1 under "0 - Sub-mods"). Measuring costs a little: about 0.1 to 0.3 ms per frame, shown in the reports. Switch it off when done.

Settings (F1)

In F1 these are under Lag Meter - ..., below the switches.

Data

Setting Default What it does
Write data file on One line per second with everything measured, in BepInEx\LagMeter\ (a new file per world visit), for analysis afterwards.
Time mods on Also time the updates of every mod's own components (labelled with the mod). Takes effect when a world loads.
Time every component (deep) on Also time the updates of every game component type around you ("game: Fireplace.Update"), so all script time is accounted for. Adds a fraction of a microsecond per timed call (the reports show the calls per frame). Takes effect when a world loads.

General

Setting Default What it does
Enabled on Measure and log. Turn off (or switch the sub-mod off) when done.
Interval (seconds) 10 Seconds per [Lag] line in the log (a short report of that time). (range 2 to 120)
Mark key F9 Press when something feels laggy: writes a [Mark] report of the last 10 seconds and marks the moment in the data file.

Low FPS

Setting Default What it does
FPS threshold 40 A second below this many frames per second gets a [LowFPS] report: what held the frame back and what was unusual. (range 10 to 240)
Report every (seconds) 10 While the frame rate stays low, another [LowFPS] report this often (each one covers the time since the last). (range 2 to 120)
Spike frame (ms) 100 A single frame slower than this gets a [Spike] line with that frame's own breakdown (at most one every 2 seconds). (range 30 to 2000)