|
JMeter example source code file (best-practices.xml)
This example JMeter source code file (best-practices.xml) is included in the DevDaily.com
"Java Source Code
Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.
The JMeter best-practices.xml source code
<?xml version="1.0"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!DOCTYPE document
[
<!ENTITY sect-num '16'>
]>
<document prev="remote-test.html" next="boss.html" date="$Date: 2009-08-06 00:58:28 +0100 (Thu, 06 Aug 2009) $">
<properties>
<title>User's Manual: Best Practices
</properties>
<body>
<section name="§-num;. Best Practices" anchor="best_practices">
</section>
<section name="§-num;.1 Limit the Number of Threads" anchor="limit_threads">
<p>Your hardware's capabilities will limit the number of threads you can effectively
run with JMeter. It will also depend on how fast your server is (a faster server
gives makes JMeter work harder since it returns request quicker). The more
JMeter works, the less accurate its timing information will be. The more work
JMeter does, the more each thread has to wait to get access to the CPU, the more
inflated the timing information gets. If you need large-scale load testing, consider
running multiple non-GUI JMeter instances on multiple machines.</p>
</section>
<section name="§-num;.2 Where to Put the Cookie Manager" anchor="put_cookie_manager">
<p>See Building a Web Test
for information.</p>
</section>
<section name="§-num;.3 Where to Put the Authorization Manager" anchor="put_auth_manager">
<p>See Building an Advanced
Web Test</a> for information.
</section>
<section name="§-num;.4 Using the Proxy Server" anchor="proxy_server">
<p>Refer to for details on setting up the proxy
server. The most important thing to do is filter out all requests you aren't
interested in. For instance, there's no point in recording image requests (JMeter can
be instructed to download all images on a page - see <complink name="HTTP Request"/>).
These will just clutter your test plan. Most likely, there is an extension all your files
share, such as .jsp, .asp, .php, .html or the like. These you should "include" by
entering ".*\.jsp" as an "Include Pattern". </p>
<p>Alternatively, you can exclude images by entering ".*\.gif" as an "Exclude Pattern".
Depending on your application, this may or may not be a better way to go. You may
also have to exclude stylesheets, javascript files, and other included files. Test
out your settings to verify you are recording what you want, and then erase and start
fresh.</p>
<!--TODO: most uses for include/exclude are now
covered by the Grouping features. include/exclude may still be useful to filter hosts out, so
that regular browsing with the proxy enabled and the browser configured won't fill your test
plan with crap. Think about other uses. -->
<p>The Proxy Server expects to find a ThreadGroup element with a Recording Controller
under it where it will record HTTP Requests to. This conveniently packages all your samples under one
controller, which can be given a name that describes the test case.</p>
<p>Now, go through the steps of a Test Case. If you have no pre-defined test cases, use
JMeter to record your actions to define your test cases. Once you have finished a
definite series of steps, save the entire test case in an appropriately named file. Then, wipe
clean and start a new test case. By doing this, you can quickly record a large number of
test case "rough drafts".</p> |