Profile the elapsed time in Java

Image for post
Image for post

Everything matters when it delivered on time, so why not the same rule applies for your programming unless you are developing a system for turtles.

Getting the execution time of a bunch of methods together in one line will not give you an accurate time. You can execute each method in Java runnable class to measure the elapsed time of each and every method with the identification name.

The below method is a demonstration of getting elapsed time of “myMethod()” by executing the method inside a runnable interface into “ProfileTime.exec()” static method.

Copy the ProfileTime class into your project and start profiling your application right now.

Image for post
Image for post
Run the method inside the profiler

Have you done it already? I mean push-ups if not start it from today.

The output is (I mean this program) ;)

Image for post
Image for post
Console output of the program

Like to review the code? You can check it in my Gist.

That’s all you can now profile the time of your methods and save much time.

Enjoy your coffee :)

Thank me later.

I’m Aslam Anver find me on GitHub and StackOverflow as aslamanver & Googlian

Passionate in AI Deep Learning, Find me on GitHub & StackOverflow

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store