Anurag Swaym wrote:The above 4 steps should give me some basic info. Are there any other steps or checks to do to see if the operation is really expensive or not? For now, I am not considering any I/O or DB operations.
Well, first off, you're likely to need to run it
many times. Don't forget that when we're talking about 'expensive' in computer terms, we may be talking about something that takes 1/10th or 1/100th of a second, as opposed to
nanoseconds. When I'm timing things, I usually average them over at least 10,000,000 invocations - mind you, I'm usually
testing pretty low-level stuff. But I'd certainly pick a figure that takes several seconds (and possibly even minutes) to run; and that will probably take some trial and error.
Also, your check doesn't appear to include monitoring other possibly limited resources, such as device handles; although you'd probably need to do this outside Java.
Finally, testing in single-threaded mode may give you some idea of what's happening, but it fairly obviously won't give you any indications of what happens under load; and that's often where 'bottlenecks' occur.
HIH
Winston