aspose file tools*
The moose likes JSP and the fly likes Fragment Timing/Profiling Taglib? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Fragment Timing/Profiling Taglib?" Watch "Fragment Timing/Profiling Taglib?" New topic
Author

Fragment Timing/Profiling Taglib?

Andreas Schildbach
Ranch Hand

Joined: Jan 22, 2003
Posts: 34
Hello everyone,
Does anyone know of a Taglib that allows to measure the time needed to "execute" the body content? Something like:
<time:time var="timevalue">
...fragment to be measured...
</time:time>
time needed: ${timevalue} milliseconds.
Regards,
Andreas
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61654
    
  67

That shouldn't be too hard to code up. Perhaps this would be a great opportunity to learn how to write simple custom actions.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Hans Bergsten
Author
Ranch Hand

Joined: Dec 01, 2003
Posts: 106
Originally posted by Andreas Schildbach:
Hello everyone,
Does anyone know of a Taglib that allows to measure the time needed to "execute" the body content? Something like:
<time:time var="timevalue">
...fragment to be measured...
</time:time>
time needed: ${timevalue} milliseconds.
Regards,
Andreas

There may be a tag library available for this that I'm not aware of, but this is a case where a tag library may be overkill and a couple of simple scriptlets may be a better choice (assuming it's just used during development; if you need this in production it's a different matter):
<% long start = System.currentTimeMillis(); %>
...fragment to be measured...
time needed: <%= System.currentTimeMillis() - start; %> milliseconds.
[ March 11, 2004: Message edited by: Hans Bergsten ]

Hans Bergsten, hans@gefionsoftware.com<br />Author of O'Reilly's<br />- JavaServer Pages,<br />- JavaServer Faces<br /><a href="http://www.hansbergsten.com/" target="_blank" rel="nofollow">http://www.hansbergsten.com/</a>
Nicholas Cheung
Ranch Hand

Joined: Nov 07, 2003
Posts: 4982
Sometimes, for keeping the code clean, we will try to use complicated ways to handle simple functions, and this is one of the cases.
I think the rule of thumb is, keep the code as clean as possible, however, only if we dont need to write complicated or complex codes. Since we now only need 2 "single-line" scriptlets, it may not worth to write a simple tag.
However, if this *scriptlet* is executed for every page, say 50 pages, then, of course, converting it into Simple Tag is better.
Nick


SCJP 1.2, OCP 9i DBA, SCWCD 1.3, SCJP 1.4 (SAI), SCJD 1.4, SCWCD 1.4 (Beta), ICED (IBM 287, IBM 484, IBM 486), SCMAD 1.0 (Beta), SCBCD 1.3, ICSD (IBM 288), ICDBA (IBM 700, IBM 701), SCDJWS, ICSD (IBM 348), OCP 10g DBA (Beta), SCJP 5.0 (Beta), SCJA 1.0 (Beta), MCP(70-270), SCBCD 5.0 (Beta), SCJP 6.0, SCEA for JEE5 (in progress)
 
Don't get me started about those stupid light bulbs.
 
subject: Fragment Timing/Profiling Taglib?