Back to FAQs

Can I set timers to measure key transactions in my test script?

Most of the time, Loadster automatically measures the important response times, without you having to do anything. When you run a load test these show up on the Response Times graph.

With Protocol Bots, the Response Times graph shows one series for each URL. For Browser Bots, the Response Times graph shows one series for each navigation change, which is essentially any action that causes the browser’s URL bar to change.

But occasionally, you might want to measure and report how long it takes to do other things too.

For example, you might have a 3-step login flow and you want to track a single measurement that tells how long it takes to perform all 3 steps successfully. Or you might have a browser script that clicks on an element and then waits for a spinner overlay, representing some background action, to disappear.

In these cases, you can track them as custom transactions using timers.

Setting custom transaction timers

In such cases you can set a custom timer in a code block to set custom timers. The duration of time between starting the timer and stopping it is reported on the Response Times graph.

The first way to start and stop a timer is by calling startTimer and stopTimer with the transaction name you want to show up on the report. As soon as the timer is stopped the custom transaction is reported.

bot.startTimer("My Checkout Flow");

// Do some things here, in the same code block or as separate steps

bot.stopTimer("My Checkout Flow");

The second way is to run all the timed actions in a callback. With this approach, anything that happens in the callback function will be timed and reported as a transaction.

bot.timer("My Checkout Flow", () => {
  // Do some things

Either of these approaches will cause “My Checkout Flow” to appear in the Response Times graph when you run a load test.