PowerShell Profiling

Developer Support

In the following post, Premier Developer Consultant Lizet Pena De Sola shows us how to analyze the performance of PowerShell scripts to pinpoint code with high CPU consumption and optimize resource usage.

As part of my job I help developers take a closer look at the source code and analyze it under the “microscope”. Part of this analysis is profiling the performance of different components of a solution for CPU usage, network usage, IO, and memory usage. I try to pinpoint areas of the code that consume the resources and see if there can be optimizations. This is what is known as profiling an application or a solution.

Visual Studio 2017, Community, Professional, and Enterprise editions all offer profiling and performance analysis tools. They cover a variety of languages and types of targets to be profiled. The image below shows the different profiling targets that can be analyzed with the Performance Profiler:

Performance Profiler in VS 2017

In the world of DevOps, part of the build automations are done using scripting languages, and one of them is PowerShell. After one of the training sessions on performance analysis and profiling with VS 2017, the question was posed:

How can we analyze the performance of PowerShell scripts to determine the areas of the code that consume the most CPU and take the most time to complete?

You can read more on Lizet’s post here.


Discussion is closed.

Feedback usabilla icon