Slowing down your Script

Sometimes for various reasons you may want your script to play more slowly than Badboy does it by default. Some situations where this is useful include:

  • You want to simulate a realistic time between user actions ("think time"). This is particularly useful when using Threads to test your web site or application under load.
  • Badboy plays an item in the script before the web page is ready. Badboy tries to wait automatically for for the page to be ready before moving to play the next item in your script. Sometimes, however, the page may still be busy doing activity that Badboy can't detect, and you might want to make the script wait until the page is really ready.

In Badboy the way to do this is to use Timers. This section describes how to use Timers in Badboy.

Adding Timers

To add a Timer, just drag the Timer Tool from the Toolbox to the place in your script where you want Badboy to pause.

If you can't find the Toolbox tab, just press Ctrl-T to display it.

Once you drop a Timer item into your script, the Timer Properties dialog will show so that you can set the Timer's options

Waiting for Fixed Time

The simplest use of Timers is just to wait for a predetermined time to expire. To do this, just select the "Fixed" option in the properties dialog and enter the amount of time in the "Time to Pause" box in milliseconds.

Waiting for a Random Time

Sometimes it is useful to be able to wait for a random time. This is especially the case when you have multiple threads running and you would like to simulate realistic "random" pauses when browsing.

To use random times, just select the "Random" option in the properties dialog and the minimum and maximum amount of time to wait in milliseconds into the provided fields. Each time the Timer plays it will select a random time to wait within the range you specified.

You can use variable references in the time fields to make Badboy wait for a time that is the value of a variable. To do this just enter the variable in the form "${variable name}".

Using Checks with Timers

Timers can do more than just wait for a fixed time to expire. They can wait for conditions about the page to become true by using Checks. To add a Check to a Timer, just drag it from the Checks tab (usually, this is next to the Tools tab), and drop it onto the Timer item. The properties dialog for the Check will show so that you can set its attributes.

When a Timer has Checks added beneath it, it will wait for all the Checks to become true before it continues, and the time set in the "Time to Pause" box has expired.

Summary Check Properties Dialog

If a Check that you have added never becomes true, Badboy will pause forever at the Timer item waiting for it. To avoid this you can set a Timeout on the Timer or the Step that contains it to take appropriate action if this happens.

Cascading Timers

If you want to make Badboy pause after every item in your script then adding Timers after each item will get very tiresome. To avoid this, you can select the option "Cascade delay to following items". When used in this mode, a Timer is called a Cascading Timer.

A Cascading Timer will pause not just when it is played itself, but also after every item that follows it or is beneath it in the script. This means that you can simply add a Cascading Timer at the start of a Step to make all the items in that Step pause for a fixed amount of time.

Badboy uses high performance counters built into most computers to measure time for Timers. On some platforms or hardware configurations, these timers may not be supported. If you find Timers are not waiting for the correct amount of time, or if you find that response times recorded by Badboy seem to be innaccurate by an order of magnitude or more, set the environment variable BADBOY_USE_TICKCOUNT_TIMER on your computer. This will cause Badboy to fall back to less accurate but more commonly available timers.


Badboy Documentation Generated on Mon Dec 29 22:28:43 EST 2008