2010-04-14 - Jakarta Taglibs has been retired.

For more information, please explore the Attic.

The "Benchmark" Tag Library

Introduction

In dicussions about how best to design tag libraries, issues of performance sometimes arise. The simple 'benchmark' tag library should aid in the performance testing of other taglibs and JSP pages in general. This library isn't a full-featured benchmarking package. It's just a simple way to get rough data if you want to sketch the relative performance of tags, tag combinations, or arbitrary JSP fragments.

Usage

duration

    <benchmark:duration> ... </benchmark:duration>

Calculates and prints the number of milliseconds taken (in elapsed, "clock" time) to calculate its body. The number is printed after the body. This tag can be enclosed by <datetime:format> with an appropriate formatting string (i.e., just referring to hours, minutes, and seconds) to print out a reasonably readable duration.

Attribute Required? Description Default
repeatoptionalnumber of repetitions1
outputoptionalif "true," the tag's body is outputfalse
(output is hidden)

exclude

    <benchmark:exclude> ... </benchmark:exclude>

Excludes its body from the overall benchmarking test. Some small amount of time is necessary to process these tags themselves, so they are not completely transparent. Nonetheless, they may be useful for integrated timing of a subset of a compound computation.

<benchmark:exclude> effectively "pauses" the timer of its nearest ancestor <benchmark:duration> tag while it runs.

Example uses:

    <%-- Typically returns between 1000 - 1010 on my system. --%>
    <benchmark:duration>
        <% Thread.sleep(1000); %>
    </benchmark:duration>

    <%-- Typically returns about 1010 on my system. --%>
    <benchmark:duration>
        <% Thread.sleep(1000); %>
        <benchmark:exclude>
            <% Thread.sleep(1000); %>
        </benchmark:exclude>
    </benchmark:duration>

This isn't meant as a full-strength benchmarking package. It's just a simple way to get rough performance data if you want to sketch the performance of certain tags, tag combinations, or arbitrary JSP fragments.