Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Fragment Timing/Profiling Taglib?

 
Andreas Schildbach
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64631
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That shouldn't be too hard to code up. Perhaps this would be a great opportunity to learn how to write simple custom actions.
 
Hans Bergsten
Author
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Nicholas Cheung
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic