In dicussions about how best to design tag libraries, issues of
performance sometimes arise. I figured a simple 'benchmark' tag library
would aid performance testing of other tag libraries.
Here's the simple interface. I'm not a benchmarking expert, so there are
likely other features that could be added.
...
Calculates and prints the number of milliseconds taken (in
elapsed, "clock" time) to calculate its body. The number is
printed after the body. As a hack, this tag can be enclosed by
with an appropriate formatting string (i.e.,
just referring to hours, minutes, and seconds) to print out a
reasonably readable duration.
Attributes:
repeat (optional) number of repetitions (default: 1)
output (optional) if "true," the tag's body is output
(by default, it is hidden)
...
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.
effectively "pauses" the timer of its nearest
ancestor tag while it runs.
Example uses:
<%-- Typically returns between 1000 - 1010 on my system. --%>
<% Thread.sleep(1000); %>
<%-- Typically returns about 1010 on my system. --%>
<% Thread.sleep(1000); %>
<% Thread.sleep(1000); %>
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.
- Shawn Bayern