Cheesy Web Server Performance Test With PowerShell

Instead of writing WCAT scripts I wrote my own little perf test client. The following .PS1 script works pretty well to do some very basic performance testing. Just enter the URL and the duration in seconds, e.g. ".\webperf.ps1 http://localhost/ 15".

The script instantiates the Net.WebClient class and calls the DownloadString member to make a HTTP request. The response is redirected to $null. The script checks on every request if the duration is expired. It reports every 100 successful responses.

param 
( 
    [string]$url, 
    [int]$duration 
) 
 
"URL: $url"; 
"Duration: $duration seconds`n"; 
 
$starttime = get-date; 
$i=0; 
$webClient = new-object Net.WebClient; 
 
while (1) 
{ 
    $webClient.DownloadString($url)>$null; 
      $i++; 
      $timespan = new-timespan $starttime; 
      if ($timespan.TotalSeconds -ge $duration) 
      { 
           "`n`n$i requests for url $url served in $duration seconds." 
           break; 
      } 
      else 
      { 
           if ($i%100 -eq 0) 
           { 
                $dursec = [int]$timespan.TotalSeconds;    
                write-host -noNewLine "`r$i requests served ($dursec seconds)"; 
           } 
      } 
}
 

Requesting the IIS default page I am able to get around 48000 requests per minute (800 per second) on my Lenovo T61p on Vista Ultimate SP1. How many can you do?

 

No Comments