I have got stucked where one of my function is taking some time to execute. I have a hierarchy of objects in object using object models and ArrayList(s). I just want to know the techniques by which I can debug the code to check which statement of code is taking time in execution.
You can use the nanoTime() method to get the time in nanoseconds. These are some of the ways of finding the method execution time of any method.
The CPU time is represented by the data type clock_t, which is the number of ticks of the clock signal. By dividing the number of clock cycles by the clocks per seconds, you have the total amount of time a process has been actively using a CPU after an arbitrary event.
The currentTimeMillis() method returns the current time in milliseconds. To find the elapsed time for a method you can get the difference between time values before and after the execution of the desired method. The nanoTime() method returns the current time in nano seconds.
Simply use this.
long startTime = System.nanoTime();
YourMethode();
long endTime = System.nanoTime();
long MethodeDuration = (endTime - startTime);
Two solutions :
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