Hello again,
I would like to improve the performance of a tag-lib I have created.
Some obvious optimizations would be to turn things like:
---------------
out.print(" href=\""+href+"\"");
//title is optional
if (!title.equals("")) {
out.print(" title=\""+title+"\"");
}
---------------
into (is this what they call "string internalization"?):
---------------
final static String HREF_ATT = " href=\"";
final static String TITLE_ATT = " title=\"";
:
StringBuffer sb = new StringBuffer();
:
sb.append(HREF_ATT);
:
out.print(sb.toString());
---------------
Before I start applying these changes, though, I would like to be able
to sort of measure the improvements.
I tried something as basic as:
<%
long startTime = System.currentTimeMillis();
%><%@ taglib uri="/WEB-INF/tld/wall.tld" prefix="wall"
%><wall:document><wall:xmlpidtd />
:
<wall:body>
<wall:menu colorize="true" autonumber="true">
<wall:a href="http://url1" title="Games">Games</wall:a>
<wall:a href="http://url2" title="Horos">Horoscopes</wall:a>
<wall:a href="http://url1" title="Kids">Kids</wall:a>
<wall:a href="http://url2"
title="Movies"><wall:b>Movies</wall:b></wall:a>
<wall:a href="http://url1" title="Music">Music</wall:a>
<wall:a href="http://url2" title="Radio">Radio</wall:a>
<wall:a href="http://url2" title="TV">TV</wall:a>
</wall:menu>
</wall:body>
</wall:document>
<%
long stopTime = System.currentTimeMillis();
long elapsedTime = stopTime - startTime;
System.out.println(elapsedTime);
%>
the problem is that when I reload the page, the number of milliseconds
is zero and occasionally 8,9 or 10
(I see output in the tomcat console running on my laptop, so I am sure
that the browser is not caching).
Questions:
- is there something I am getting basically wrong?
- is my tag-lib optimized enough that I don't need to care about further
optimization? possibly
because the compiler/JVM already did the optimization for me?
- are there better ways/tools to measure tag-lib performance?
Thanks
Luca
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]