ant.jar
commons-collections-2.1.jar
commons-digester-1.5.jar
commons-httpclient-2.0-rc2.jar
commons-jelly-1.0-beta-4.jar
commons-jexl-1.0-beta-2.jar
commons-logging-1.0.3.jar
commons-beanutils-1.6.1.jar
checkstyle-3.4.jar (and associated dependencies, like antlr.jar)
junit-3.8.1.jar
<target name="benchmark" description="Runs the benchmarks" depends="tasks">
<delete file="${benchmark.log}"/>
<property name="threads" value="5"/>
<property name="duration" value="60"/>
<property name="delay" value="0"/>
<taskdef name="benchmark" classname="net.sf.jbenchmark.BenchmarkTask">
<classpath>
<path refid="project.class.path"/>
</classpath>
</taskdef>
<benchmark>
<script path="scripts/benchmark.all.xml"/>
<httpserver hostname="${benchmark.host}" port="${benchmark.port}" threadSession="true"/>
<publisher logfile="${benchmark.log}"/>
</benchmark>
</target>
The <benchmark> task takes the following attributes:
| Attribute | Description |
|---|---|
| logfile | The log file to write results to. The benchmark results are appended to this file. If not specified, the results are written to Ant's stdout. |
| script | A benchmark script to be executed. |
The <benchmark> task takes the following nested elements:
The <script> element defines a benchmark script to execute. It takes the following attributes:
| Attribute | Description |
|---|---|
| path | A benchmark script to be executed. |
The benchmark tool is a simple HTTP benchmarking tool. Benchmarks are defined in an XML based benchmark script, and an Ant task is used to execute the script.
<test>
<!-- Hit the web page with multiple threads, for a fixed duration -->
<web-page prefetchCount="15" prefetchDelay="500" threads="${threads}" duration="${duration}" delay="${delay}"
path="/path/" name="index.xml">
<assert-response-status status="200"/>
<assert-response-size max="20000"/>
</web-page>
</test>
<test xmlns:jelly="jelly:core" xmlns:util="jelly:util">
<thread-group threads="5">
<loop-duration duration="120">
<jelly:import uri="include/sitesearch.xml" inherit="true"/>
</loop-duration>
<timer name="Preload times only (get the server and caches warmed up)"/>
</thread-group>
<thread-group threads="${threads}">
<loop-duration duration="${duration}">
<jelly:import uri="include/sitesearch.xml" inherit="true"/>
</loop-duration>
<timer name="search times"/>
</thread-group>
file:include/sitesearch.xml
<choose-random>
<!-- 80% of hits are searches with partial property name-->
<choice weight="80">
<!-- 50% of searches have accomodation type set -->
<random var="accommType">
<token-list tokens=",,,1,2,3"/>
</random>
<random var="propertyName">
<sql-list query="select substring(DisplayName, 1, 4) from PROPERY"/>
</random>
<http-get path="/Search.jsp?propertyName={propertyName}&accomodationType={accommType}">
<assert-response-status status="200"/>
<assert-response-size min="1000" max="600000"/>
</http-get>
<timer name="searchby.propname"/>
</choice>
<!-- 20% of searches by region -->
<choice weight="20">
<random var="regionid">
<sql-list query="select id from REGION"/>
</random>
<http-get path="/Search.jsp?region={regionid}">
<assert-response-status status="200"/>
<assert-response-size min="1000" max="600000"/>
</http-get>
<timer name="searchby.region"/>
</choice>
</choose-random>
A benchmark script is an XML file. The root element of the script must be a <test> test group element.
Script are interpreted as Jelly scripts, and so can include
Jelly tags in addition to the tags listed below. In particular, the <import> tag can be used to import
other scripts. Scripts can access Ant properties using Ant-style ${property-name} expressions.
Test group elements defines a group of tests to execute. The tests are defined as nested elements, and are executed in the order that they appear in the script.
The <loop> element defines a test group that executes multiple times.
the element takes the following attributes:
| Attribute | Description |
|---|---|
| count | The number of times to execute the test group. |
The <loop-duration> element defines a test group that executes multiple times, for a fixed amount of
time. This element takes the following attributes:
| Attribute | Description |
|---|---|
| duration | The amount of time (in seconds) to execute the test group. |
The <thread-group> element defines a test group that executes concurrently in multiple threads. Each
thread executes the test group once. This element takes the following attributes:
| Attribute | Description |
|---|---|
| rampup | The amount of time (in seconds) to take to start the threads. |
| threads | The number of threads to use. |
The <parallel> element defines a test group that executes each of its tests in parallel.
Test elements define a single atomic test to execute. They can be added to any test group element.
The <http-get> element performs an HTTP get of a particular resource.
This element takes the following attributes:
| Attribute | Description |
|---|---|
| path | The path of the resource to get. |
The <http-get> element can include nested assertion elements.
The <fixed-delay> element introduces a delay of fixed duration.
This element takes the following attributes:
| Attribute | Description |
|---|---|
| delay | The length of the delay (in milliseconds). |
The <timer> element defines a timer, which gathers timing statistics. A <timer>
element can be added to a test group, and it will gather statistics for all HTTP tests in that group (including all
nested tests).
This element takes the following attributes:
| Attribute | Description |
|---|---|
| name | An identifying name for the timer. This name will appear in the log file. |
The <assert-duration> element can be added to any test or test group element, and checks that the test
execution time does not exceed an expected maximum value.
The <assert-response-status> element can be added to any HTTP test, and checks that the HTTP response
returns the expected status code.
The <assert-response-size> element can be added to any HTTP test, and checks that the HTTP response
returns a body whose size is within an expected range.
The <http-server> element can be added to any test group, and specifies the HTTP server that all HTTP
tests in that group (including all nested tests) should use.
The <console-publisher> element can be added to any test group, and directs the output of all test
timers in that group (including all nested timers) to Ant stdout.
The <file-publisher> element can be added to any test group, and directs the output of all test
timers in that group (including all nested timers) to a log file.
