long startTime=System.currentTimeMillis(); //执行方法 long endTime=System.currentTimeMillis(); float excTime=(float)(endTime-startTime)/1000; System.out.println("执行时间:"+excTime+"s");
java中计算一个方法执行时长,耗费单位(秒)
最新推荐文章于 2024-06-20 16:50:49 发布
long startTime=System.currentTimeMillis(); //执行方法 long endTime=System.currentTimeMillis(); float excTime=(float)(endTime-startTime)/1000; System.out.println("执行时间:"+excTime+"s");