I'm trying to measure time spent on every action of my application, since I'm rebuilding a legacy system.
Right now I'm doing this at Controller level:
def actionStart() {
session.startTime = new Date().getTime()
}
def actionEnd() {
def endTime = new Date().getTime()
timeHandler(endTime, session.startTime)
}
def timeHandler(end, start){
return end - start
}
Important: I want to move it to a Filter and automatically execute it at the start and ending of every action.
What should be the best approach? Thanks in advance.
PS.: What's the difference between getting System.currentTimeMillis() and instanciating an object? Performance?
At the start of the action do Like this :
long now = System.currentTimeMillis();
at the end of the Action , do Like this :
System.out.println( (System.currentTimeMillis() - now) + " ms");
and put your action between this two line
Disclaimer:
I answered this question according to java (before the tags was edited), so please clarify your tags.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With