Freigeben über


Stress-O-Matic

A very simple stress-test

The other day I was asked by a customer if I a small application that could be used to stress a web application. I didn't feel like responding "Sure I do! Visual Studio 2005 Team Edition For Software Testers" and I also didn't feel like saying "Why don't you make one yourself using the webbrowser control?" So instead I wrote a small script. It's all very basic and simple, but I still thought it might be of use to someone. Just copy the code below into a .vbs-file and you're good to go.

Please note, however that the script relies heavily on WScript.Echo to tracks it's progress, so you should use CScript as the host rather than WScript. If you're unfamiliar with CScript & WScript I recommend taking a look at this article: MSDN: Running Scripts from Windows

CONST NUMBEROFLOOPS = 3 '****** How many times do you want the script to loop?
CONST DELAYTIME = 3 '****** How many seconds do you want to wait?
CONST URL = "https://www.microsoft.com"
Dim Http
Set Http = CreateObject("MSXML2.XMLHTTP")

Main

Function SendHTTPRequest()
   Http.Open "GET", URL , False
   Http.setRequestHeader "If-None-Match","qwerty"
   Http.setRequestHeader "Cache-Control","no-cache,max-age=0"
   Http.setRequestHeader "Pragma","no-cache"
   Http.send
   '****** Uncomment this in case you want to see the response for some reason...
   'WScript.Echo(Http.responseText)
End Function

Sub Main()
   Wscript.Echo("Test started at: " & Now())
   WScript.Echo("Will access """ & URL & """ " & NUMBEROFLOOPS & " times in " & DELAYTIME & " second intervals.")
   For I = 1 to NUMBEROFLOOPS
      WScript.Echo( I & ": Accessing """ & URL & """")
      SendHTTPRequest()
      Wscript.Echo("Waiting " & DELAYTIME & " seconds:")
      For J = DELAYTIME To 1 Step -1
         WScript.Sleep 1000
         Wscript.Echo("Waiting " & J-1 & " seconds:")
      Next
      WScript.Echo( I & ": Complete")
   Next
   Wscript.Echo("Test completed at: " & Now())
End Sub

 

That's all for now.

/ Johan

Comments

  • Anonymous
    January 17, 2008
    Use Grinder http://grinder.sourceforge.net/

  • Anonymous
    April 12, 2010
    I need to do testing for some of my web-pages to see their performance with heavy view state.  Any ideas on how that can be done?