I'm interested in finding out the best way to measure the execution time of methods within a Java web service I'm working on.
The service will be deployed to multiple clients and hence run in multiple different production environments (clients tend to have varying setups as dictacted by their requirements), and its been decided the service should log the execution time for processing requests to provide some indication of possible performance issues.
So far, most of the suggestions (such as here & here) I've seen are to use System.currentTimeMillis()
at the beginning and end of the code I'm interested in and calculate elapsed time, but is that really the best solution to this problem for a production environment?
How suitable is System.currentTimeMillis()
for measuring method execution time, and are there any alternatives?
EDIT 0: To clarify, a key requirement is that this execution measurement should be deployed as part of the standard deployment to collect data so that it can be referred to should a performance related support issue be raised, as the service forms part of a complex system of new and legacy components