Reputation: 11
i saw your below thread. I was also trying to do similar thing but not sure which api would give the best result: can u please suggest which one you used?
Using the MethodEntry and MethodExit event hooks provided by the JVMTI how would I measure the time of a method executed in Java?
In simple means it's just: time2 - time1 but the problem I see, how to I distinguish between the different methods? There is a methodID, but what about recursive calls? When is a method closed after it was opened?
Should I compare the stack trace? What would be a meaningful data structure to trace the methods which where entered? Something like Map?
Upvotes: 0
Views: 281
Reputation: 126
Using the MethodEntry and MethodExit events to record method timing is probably not a very good strategy, since using those events will severely disrupt the timing. You might hope that the distruption is going to be equal for all methods, and you could still get the relative time, but I'm not sure that is true.
A better strategy would be to use bytecode instrumentation to track these events.
Upvotes: 2