Read the systemtime just before the method is invoked and immediately after method returns.Take the time difference, which will give you the time taken by a method forexecution.To put it in code...long start = System.currentTimeMillis ();method ();long end = System.currentTimeMillis ();System.out.println ("Time taken forexecution is " + (end - start));Remember that if the time taken for execution istoo small, it might show that it is taking zero milliseconds for execution. Tryit on a method which is big enough, in the sense the one which is doingconsiderable amout of processing.
共 1 个关于本帖的回复 最后回复于 2013-8-16 16:03