简体   繁体   中英

Compile time and runtime processing of a code in java

I have a piece of Java code and I compiled and ran it. I got an output and I made some changes to it, before compiling and running again.

Is there any difference between the time it takes during the first compilation compared to the second compilation. Similarly are there changes between the first runtime to second runtime? Is there any way to find that difference in processing time?

There can be certain difference according to the changes you have made. It depends on what your program did and what it does now, i think you can understand that.

To check the time, you can do this by creating a thread that can act like a timer just after the program execution, and stop that thread after all your processes have been done and simply display to see the time.

Firstly, I'm unsure why this is important to you. Perhaps by providing some more context you will get a more detailed answer.

Comparing compilation time can be achieved using Operating System tools. For example, on Linux try using time .

Complete execution time of your two Java programs can be achieved in the same fashion. However, if you are looking more closely at whether your code changes have improved your execution performance, I would suggest you Google "benchmarking in Java" to find a wealth of information on the correct methods to benchmark code.

If you use Eclipse you can configure Project -> Build Automatically to rebuild the project after every change. So once you want to run it would take minimal time.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM