Search code examples
visual-studio-codeactivity-monitor

Is there an activity monitor for VS Code and VS Code extensions?


The other day I was using my laptop unplugged and it went from fully charged to 10% in 3 hours. Normally the battery would last all day. Long story short VS Code was obliterating my battery life. VS Code's energy usage appears to be almost 30 times higher than Chrome, the #2 energy user. I'm not doing anything crazy – just some Shopify and Laravel templating – but I'm assuming it's because of some of my extensions, not VS Code itself.

enter image description here

Does anyone know of a way to show CPU usage per extension? I looked around but didn't find anything. Or is there some other way I can track down the culprit? I think CPU usage over a long period of time (like a few hours) would be more useful than current usage.


Solution

  • VS Code has a process explorer, which you can open with the Developer: Open Process Explorer command in the command palette. You can find extension-related processes under the "extensionHost" tree item. Not every active extension will be shown there since this is just for extensions that run their own child processes, and it's only showing those child processes. It'll show CPU and memory usage.

    You can get similar information from using other system tools like an Activity Monitor / Process Manager tool, or htop.

    Note that VS Code is built on Chromium, so you can also use Chromium's profiling tools. Open the devtools with the Developer: Toggle Developer Tools command in the command palette, and got the "Performance" tab, where you can capture performance traces. There's also the overall "Performance monitor" view (open the devtools console and click the three dot menu to find it).

    If VS Code is consuming a lot of CPU, see also https://github.com/microsoft/vscode/wiki/Performance-Issues#consuming-cpu.