Published on ONJava.com (http://www.onjava.com/) http://www.onjava.com/pub/a/onjava/2003/01/15/jmeter.html See this if you're having trouble printing code examples
by Budi Kurniawan 01/15/2003 JMeter is a Java-based tool for load testing client-server applications. Stefano Mazzocchi originally wrote it to test theperformance of Apache JServ (the predecessor of Jakarta Tomcat). It has since become a subproject of Jakarta.
Installing and Running JMeter
The most recent release of JMeter is version 1.8. You can download the latest stable version from JMeter's site. Downloads area available as either .gz or .zip files. JMeter 1.8 requires a working JDK 1.4 environment. Once you extract the binary distributionfile, JMeter is ready for you. On Linux/UNIX, run JMeter by invoking the jmeter shell script. On Windows, call the jmeter.bat file. Both files can be found in the bin/ directory of the JMeter installation directory. Figure 1 shows JMeter's main window, which is a Swing application.
1 of 8
7/26/2007 3:35 PM
ONJava.com: Using JMeter
Figure 1:JMeter's main window. The user interface has two panes. The left pane displays the elements used in our testing. Initially, there are the Root and two sub-elements, Test Plan and WorkBench. In this article we're only concerned with Test Plans. Add an element to a node by right-clicking it and selecting Add. To remove an element, select the element by clicking on it, then right-click on the element andchoose the Remove option. The right pane of the user interface displays the details of each element. You are now ready to use JMeter. There are two things to note: 1. You should not run JMeter on the same machine running the application to be tested. JMeter may use extensive resources that might affect the other application's performance if they are both run on the same machine. 2. Make sure thatthe testing is affected as little as possible by network traffic. The best thing to do is to ask your network administrator to set up an isolated sub-network for the machine running the Web application and the machine running JMeter.
Using JMeter for a Simple Test
Let's start with a very simple test. In this test, we will set up a test plan and stress test a Web application. You will beintroduced with some common concepts in JMeter. After understanding this basic test, you should be able to use all of the capabilities of JMeter. To conduct a test, you must have a test plan. A test plan describes the steps that JMeter will take to perform the testing. A test plan includes elements such as thread groups, logic controllers, sample generating controllers, listeners, timers, assertions, andconfiguration elements. Don't worry at this stage if you don't understand what these elements are. A test plan must have at least one thread group. A thread group is the starting point of a test plan, and it can contain all other JMeter elements. A thread group controls the threads that will be created by JMeter to simulate simultaneous users. Now, let's start by creating a thread group.Right-click the Test Plan element and select Add and then Thread Group. JMeter will create a thread group element under Test Plan element. Click the Thread Group element, and you will see a screen like the one in Figure 2.
Figure 2: Configuring a thread group.
2 of 8 7/26/2007 3:35 PM
ONJava.com: Using JMeter
In this page, you can set the following properties:Name -- the name of this thread group. You can give a descriptive name to this property. Number of Threads -- the number of threads created. Each thread represents a single user. Therefore, if you want to simulate a load test with 10 concurrent users, enter 10 as the value for this property. Ramp-Up Period -- the number of seconds JMeter will take to accelerate to create all of the threads...