long startTime = System.currentTimeMillis(); // 时间戳
(要计算耗时的代码)
long endTime = System.currentTimeMillis(); // 时间戳
System.out.println( endTime-startTime); //时间为毫秒数
java 计算某段代码耗时(时间戳)
于 2021-07-10 07:24:17 首次发布
long startTime = System.currentTimeMillis(); // 时间戳
(要计算耗时的代码)
long endTime = System.currentTimeMillis(); // 时间戳
System.out.println( endTime-startTime); //时间为毫秒数