Skip to main content

How to measure website speed in your internal network?

When it comes to finding out an external website’s speed, Pingdom Website Speed Test is the first tool that comes to mind. Google PageSpeed Insights and GTmetrix are other useful tools to measure and troubleshoot your external site’s speed.

What about internal sites? Since these sites are not open to public, tools like Pingdom or GTmetrix won’t be able to analyze them. I will mention a quick way of measuring your website’s speed in this post.

Measure website speed in internal network

Determining your website’s load speed is as easy as running a small PowerShell script. Well, technically, you can just load it on a browser and check the timing in a chronometer but it wouldn’t give precise results.

I developed two PowerShell scripts for this purpose:

  1. Show the speed of an URL. Check only once
  2. Show the average speed of an URL after checking it for X number of times

Speed of an URL (One check only)

Copy the following code and paste it in a notepad file. Save it as ps1 file (Example: SiteTest.ps1). Then run it to see the exact load speed of your website.

$url = 'http:\\localhost'

$timeTaken = Measure-Command -Expression {
    $site = Invoke-WebRequest -Uri $url
}

$seconds = [Math]::Round($timeTaken.TotalSeconds, 4)

"The page took $seconds seconds to load" 
Measure website speed

If you are not happy with your IIS website speed and you want to improve it, check this detailed article about performance improvement: 9 Easy and Practical Recommendations to Improve IIS Performance

Average speed of an URL (Check X times)

By enhancing the code in the previous section, we can test the URL multiple times and calculate the average. For example, the code below checks the speed 100 times and shows the average value along with each test’s result.

# CHANGE THESE TWO VALUES #
$url = 'http://localhost/'
$totalRequest = 100
 
# NO NEED TO MAKE A CHANGE BELOW THIS LINE #
$totalSeconds=0
$individualRequests = ""
 
For ($i=0; $i -lt $totalRequest; $i++)  {
 
    $timeTaken = Measure-Command -Expression {
        $site = Invoke-WebRequest -Uri $url
    }
 
    $roundedSecond = [Math]::Round($timeTaken.TotalSeconds, 4)
    $totalSeconds += $roundedSecond
    $individualRequests += $roundedSecond.toString() +  "  -  "
 
    Start-Sleep -m 200
}
 
$averageSeconds = $totalSeconds / $totalRequest
""
"Average of $totalRequest requests is $averageSeconds"
""
"Individual requests: $individualRequests" 

Please make sure to update url and totalRequest variables before running the script.

Another way of monitoring your site speed is that using performance counters in Windows. Check this post out for more information: 5 Useful Performance Counters to Monitor for IIS

Leave a Reply

Your email address will not be published. Required fields are marked *