Words: 414
Time to read: ~ 2 minutes
I would consider myself a passive Twitter user.
Apart from catching up on news during my commute I only really use notifications for a certain number of hashtags i.e. #SqlServer, #tsql2sday, #sqlhelp, and #PowerShell.
So during work, every so often a little notification will pop up on the bottom right of my window and I can quickly glance down and decide whether to ignore it or check it out.
That’s what happened with the following tweet:
Now I’m always trying to improve my knowledge on PowerShell so when this notification pops up I glance down and think to myself:
“Oh I can have that check that out on a side screen while I work away. Maybe I can learn something”
So I join in and watch it.
Man, am I glad I did. I got an insight into Boe Prox’s ( twitter | blog ) PoshRSJob and a look into the method of developing & troubleshooting a script but I also gleaned a nice little way of casting a hash table to a PSCustomObject!
Sometimes you may know that 2 * 2 * 2 * 2 = 16
but it takes seeing it in action to realize it’s the same as 2^4 = 16
.
Check it out here:
What’s the point of this post?…
Right! Sorry, sorry, I get sidetracked sometimes.
It’s all well and good to automate aspects of your job but how can you test if they scale? I can now use Start-TestCaseMeasurement
to check this out!
See for yourself:
Find-Module -name Start-TestCaseMeasurement | Select-Object -Property Name, Type, Version, Repository, Description

Find-Script
Let’s install it
Find-Module -name Start-TestCaseMeasurement | Install-Module

Right, “Run as Administrator” is needed to install scripts. My bad…

Great! But where did it go to?
Get-InstalledScript Start-TestCaseMeasurement | Select-Object -Property InstalledLocation, Name<code></code>

Install-Module -Verbose
Testing the test
Now that we have everything that we need, I’d be remiss if I didn’t show you this in action.
So let’s check out the speed of getting the ServerName using Invoke-Sqlcmd
, shall we?
. 'C:\Program Files\WindowsPowerShell\Scripts\Start-TestCaseMeasurement.ps1' -Scriptblock { Invoke-Sqlcmd -ServerInstance .\SqlServer2k16 -Database Pantheon -Query "SELECT @@SERVERNAME" } -Throttle 10 -Iterations 1000

Running this 1,000 times gave us a longest run time of only 35 milliseconds.
Exit:
Adding this to the my internal scripts mean that I can not only create scripts but also ensure that they scale as well!
And it’s still getting improved as well.
What a nice little find 🙂
Nice
I still like measure-command
Measure-Command is great and I use that for my small load testing.
When you include runspaces though, like this one does using PoshRSJobs, then you can measure AT SCALE MWAHAHAHAHA!!!
Cough…cough…ahum…sorry about that…
I will have to test that.