VMware Cloud Community
asianchurro
Contributor
Contributor

first PowerCLI cmdlet execution is noticeably slow

I wrote a powershell script to get the passthrough devices of VM(s)/host and write the pci devices uid and vm id to stdout.

However I noticed that the first execution of this script is noticeably slower than the following times I would run the script:

asianchurro_0-1646245031730.png

Here is the get_passthrough.ps1 script that I've been testing with:

asianchurro_3-1646245547442.png

Here is the PowerCLI version:

asianchurro_1-1646245306560.png

Here is the powershell version:

asianchurro_2-1646245485851.png

Is there any optimizations that I can do to the script to improve the performance and get rid of the additional 9 seconds of latency at the first run?

 

0 Kudos
1 Reply
LucD
Leadership
Leadership

I assume caching (PS and vSphere) plays a role.

It would be interesting to test how long you have to wait between running the script before the 2nd run also takes the same amount of time.
You could call your script from another script with increasing Start-Sleep in between calls.           


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos