Recently Written · git

bd-plugin-profiler

BetterDiscord plugin that measures the main-thread time of each plugin

git clone https://github.com/equwal/bd-plugin-profiler

Log | Files | Refs


README.md (1515 bytes)

1 # PluginProfiler
2 
3 PluginProfiler is a BetterDiscord plugin. It measures the main-thread time that each plugin uses. It also shows the CPU and memory use of Discord.
4 
5 ## Install
6 
7 1. Copy `00PluginProfiler.plugin.js` into the BetterDiscord plugins folder (`%APPDATA%\BetterDiscord\plugins`).
8 2. In Discord, open Settings > Plugins and turn on PluginProfiler.
9 3. Press Ctrl+R. The file name starts with `00`, so the profiler starts before the other plugins. Then it also sees the timers that the other plugins make when they start.
10 4. Open the settings of PluginProfiler to see the table. Click "Copy report" to copy the data as text.
11 
12 ## What it measures
13 
14 - Time in BetterDiscord patch callbacks, per plugin. The time of the original Discord function does not count.
15 - Time in the plugin callbacks that the BDFDB library runs, per plugin.
16 - Time in the `observer`, `onSwitch`, and BDFDB `process*` methods of each plugin.
17 - Time in the timers and observers that a plugin makes. The profiler finds the plugin from the call stack.
18 - The CPU of all Discord processes, the renderer JS heap, and long animation frames.
19 
20 The time is wall time on the main thread. It includes waits for disk and for paged-out memory, so it can be more than the CPU time.
21 
22 The profiler does not measure event listeners, async work, CSS, or memory per plugin.
23 
24 ## Tests
25 
26 Run `npm test` with Node 22 or later. The tests load the patcher of the installed BetterDiscord and `TimeUtils.suppress` of the installed BDFDB, so both must be installed.