Skarif-ProfilerValheim_Zeta icon

ProfilerValheim Zeta

A developer tool for in-game CPU profiling of BepInEx mods. Shows per-mod and per-method CPU load, spike alerts, A/B snapshots comparison and report export. Not intended for regular gameplay.

Last updated 6 hours ago
Total downloads 24
Total rating 1 
Categories Misc Tools Client-side Utility Ashlands Update Bog Witch Update
Dependency string Skarif-ProfilerValheim_Zeta-1.1.0
Dependants 1 other package depends on this package

This mod requires the following mods to function

denikson-BepInExPack_Valheim-5.4.2200 icon
denikson-BepInExPack_Valheim

BepInEx pack for Valheim. Preconfigured and includes unstripped Unity DLLs.

Preferred version: 5.4.2200

README

ProfilerValheim Zeta

Author: Skarif
Version: 1.1.0
GitHub: SkarifWW/ProfilerValheim.Zeta
Toggle overlay: F8


âš ī¸ This is not a gameplay mod.
ProfilerValheim Zeta does not add items, mechanics, or any content to your game.
It is a developer and modder tool designed for CPU profiling, performance analysis,
and debugging of BepInEx plugin assemblies inside a live Valheim session.
If you are a regular player looking to improve FPS - this is not what you need.


What is it?

ProfilerValheim Zeta is an in-game profiler that instruments other BepInEx mods at runtime using Harmony hooks and measures how much CPU time each mod consumes per frame - broken down to the individual method level.

The key difference from external profilers (like dotTrace or Unity Profiler) is that it runs inside the game, in real gameplay conditions, with your exact mod list loaded, without any separate process or build configuration. You press one button, it scans your installed mods, and immediately starts showing live data.

It was built for situations like:

  • "My FPS dropped after I installed three new mods - which one is the culprit?"
  • "I'm optimising my own mod and need to see which Update() method is the bottleneck."
  • "The game stutters every 10 seconds. I need to catch the spike and see what caused it."

Features

Live CPU Graph

A rolling 300-frame CPU load graph is drawn at the top of the profiler window.

  • White line - total load from all tracked mods combined.
  • Coloured lines - top 5 heaviest mods, each with its own colour.
  • Orange line - worst-frame rolling maximum with slow decay. This is the line that reveals spikes that averages would hide.
  • Horizontal reference lines - 60 FPS (16.6 ms, green), 30 FPS (33.3 ms, yellow), 15 FPS (66 ms, red).
  • Interactive tooltip - hover over any point on the graph to see Total ms, Worst ms, and the name of the heaviest mod at that moment.

Event Markers

Press MARK EVENT at any moment during gameplay - a green vertical stamp appears on the graph at that exact frame. Use it to correlate what you were doing with what you see on the graph (entering a dungeon, interacting with a chest, triggering a boss, etc.).

Per-Mod Table

Below the graph is a sortable table of all scanned mods:

Column Description
Mod Name Assembly name of the BepInEx plugin
Avg CPU Average self-time per frame in milliseconds
Impact Percentage of total frame budget consumed
Calls/s Number of instrumented method calls per second

Impact is colour-coded: red above 5%, yellow above 1%.

Method Drill-Down

Click any row in the mod table to expand it and see the top 10 heaviest individual methods within that assembly - with their own AvgMs and Calls/s. This is the feature that turns "mod X is slow" into "method Foo.Update inside mod X is the bottleneck".

Search & Filter

  • Live text search filters the table by mod name.
  • Hide < 0.1 ms toggle removes noise from mods that are too small to matter.

Alerts Tab

Automatic spike detection. Any mod that exceeds 16.6 ms in a single frame (the threshold for dropping one frame at 60 FPS) is recorded in the Alerts log with:

  • Timestamp (HH:mm:ss)
  • Mod name
  • Peak milliseconds

Up to 100 events are stored. The tab label shows the current count. You can clear the log at any time.

A/B Snapshot Comparison

Designed for iterative optimisation:

  1. Profile your current state → click Save as Snapshot A.
  2. Make changes to a mod (or disable something).
  3. Profile again → click Save as Snapshot B.
  4. Switch to the A/B Compare tab and see a delta table.

Delta is colour-coded: 🔴 red means the mod got more expensive, đŸŸĸ green means it improved.

Export to File

Click EXPORT to write the current state to a .txt report file at:

BepInEx/profiler_reports/profiler_YYYY-MM-DD_HH-mm-ss.txt

The report includes the full mod table with method details, all spike alerts, FPS and mod count. Useful for sharing with other developers or attaching to bug reports.


How the Profiling Works

ProfilerValheim Zeta uses Harmony Prefix/Postfix pairs to wrap instrumented methods. When SCAN MODS is pressed, it iterates all loaded BepInEx plugins and applies hooks to:

  • MonoBehaviour.Update(), FixedUpdate(), LateUpdate() of every component in each plugin.
  • Prefix and Postfix methods of every Harmony patch class found in each plugin assembly.

The profiler itself is excluded from scanning to avoid self-measurement.

Self-time is computed correctly: each method tracks how long its children took (via a per-thread call stack) and subtracts that from its own elapsed time. This means if ModA.Update calls ModB.SomeHelper, only ModB.SomeHelper's own time is charged to ModB - not the time ModA spent waiting for it.

All sample collection is thread-safe: ConcurrentDictionary + Interlocked.Add/Exchange ensure no data races even if hooks fire from background threads.


Installation

  1. Install BepInExPack for Valheim.
  2. Drop ProfilerValheim.Zeta.dll into BepInEx/plugins/.
  3. Launch Valheim and load a world.
  4. Press F8 to open the profiler overlay.
  5. Click SCAN MODS to begin instrumentation.

â„šī¸ Scanning takes a moment depending on how many mods you have installed. The status bar at the top of the window shows progress. You can click STOP SCAN at any time - already-applied hooks remain active.


Performance Impact of the Profiler Itself

Every instrumented method call goes through a Prefix and Postfix wrapper. The overhead per call is a few hundred nanoseconds (two Stopwatch.GetTimestamp() calls and some stack operations). On a typical modpack of 30–50 mods this adds up to roughly 0.1–0.5 ms total per frame - visible but not game-breaking for a diagnostic session.

When STOP MONITORING is pressed, recording is disabled at the very first line of every Prefix - the overhead drops to a single branch check, essentially zero.


Limitations

  • Only mods loaded at startup are scanned. Dynamically loaded assemblies added after game start are not automatically discovered.
  • Generic methods and abstract methods cannot be patched by Harmony and are skipped silently.
  • The profiler measures managed C# code only - native Unity engine code (rendering, physics, audio) is not visible.
  • static constructors and initialization code that runs before Awake is not captured.

For Mod Developers

If you are optimising your own mod, the most useful workflow is:

  1. Load the game with your mod installed.
  2. Open the profiler (F8) and hit SCAN MODS.
  3. Reproduce the expensive scenario in-game.
  4. Click the row of your mod in the table to expand method-level detail.
  5. Use MARK EVENT to timestamp exactly when you triggered the scenario.
  6. Click EXPORT and share the report with your team or keep it as a baseline.
  7. Make changes, restart, repeat from step 3. Use A/B Compare to quantify progress.

Compatibility

  • Valheim - tested on current Steam release.
  • BepInEx - requires BepInExPack 5.4.22+.
  • Harmony - uses the 0Harmony.dll bundled with BepInEx; no separate install needed.
  • Other mods - the profiler only adds Prefix/Postfix hooks and never modifies game logic. It is safe to run alongside any gameplay mod. However, it will interact with any mod that itself patches Update methods - this is expected and intended behaviour.

Source Code

Full source available at github.com/SkarifWW/ProfilerValheim.Zeta.
Issues and pull requests are welcome.


ProfilerValheim Zeta - see inside your modpack, fix what's slow.