Wednesday, July 16, 2008

The Taming of the JMeter: command-line arguments, tidy, bean shell


JMeter is powerful but poorly documented. Here’re few things that everyone could use:

  • In order to change User Defined variables from the command line, convert them to properties:

clip_image002

Now you can store default values in user.properties file and override them by passing -J parameter on the command line: e.g. -Jthreadcount=1 -JdataFile=data1.xml

If user.properties file has changed, jmeter must be restared.

  • JMeter allows for sophisticated XPath expressions that can be used to parse a random HTML page – just make sure to set “Use Tidy” check-box.

clip_image004

XPath expression can also include JMeter variables, e.g.

/html/body/table/tbody//tr[${__V(server${serverIndex}Section2Header)} + 2]//text()

This is pure goodness…

  • What makes JMeter even more powerful is its ability to integrate with Bean Shell – you have to copy beanshell’s bsh-2.0b4.jar to jakarta-jmeter-2.3\lib\ext and rename this as bsh.jar – that’s it… Buyer beware: invoking bean shell in a loop is awfully slow. Debugging a bean shell script is nightmare consisting of adding print statements throughout your code. Passing –LDEBUG flag may help with troubleshooting.

    Sometimes I feel it’s just easier to dump data extracted with JMeter script and analyze it with a standalone java program.

If JMeter had tighter integration with BeanShell or, even better, allowed for calling user-specified java classes within the same

JVM (to speed things up), it’d rule!

Technorati Tags: