Java big data platform development study notes (2)-how to check code running time in java

How to check code running time in java?

There are many ways to check. You can find a large piece of it on the Internet. Only one type of code is recorded here, which is convenient for checking when you forget it.

long start = System.currentTimeMillis(); 
//此处写要测试的代码
long end = System.currentTimeMillis(); 
System.out.println("共耗时"+(end-start)+"毫秒");

  • Wherein the currentTImeMillis()method of action is to return the current time in milliseconds. So the time when the test is finished minus the time when the test just started is the time it takes to execute the test code.
  • This method returns the current time in milliseconds because this millisecond is the time difference (measured in milliseconds) between the current time and midnight on January 1, 1970 Coordinated Universal Time.
  • That is: current time-the time between midnight on January 1, 1970 UTC

• Written by ChiKong_Tam on September 5, 2020

Guess you like

Origin blog.csdn.net/qq_42209354/article/details/108419393