Sunday, June 3, 2012

Think time toggle in JMeter

(revised March 31, 2013)

Simulated think time in load testing is an essential part of a good test plan.  But sometimes I want to turn think timers off (for debugging, or to build up the database).  I wanted a little more control over the think time behavior in my plans, so this is what I'm currently using. Features include:

  • There's a parameterized variable in the test plan that let me turn off the sleep behavior completely to either build out a database, or just run through a lot of tests quickly.
  • There is a parameterized variable to control the think time (the base think time actually).
  • There is fluctuation in think time (25% above or below the base) so that threads don't all wake up at the same time.
  • If the test is stopped while a thread is thinking (most will be), the thread will stop right away, and thus, the test will complete right away. This is because the test pauses in one second intervals.
  • Most of the logic is within a test fragment so that it can be re-used within the test.
Here's the example jmx file:  thinkExample.jmx