java下,计算算法,方法耗费的时间
//记录开始时间 long startTime=System.currentTimeMillis(); //此处为你调用的方法,算法 method(); //记录结束时间 long endTime=System.currentTimeMillis(); float excTime=(float)(endTime-startTime)/1000; System.out.println("执行时间:"+excTime+"s");
//记录开始时间 long startTime=System.currentTimeMillis(); //此处为你调用的方法,算法 method(); //记录结束时间 long endTime=System.currentTimeMillis(); float excTime=(float)(endTime-startTime)/1000; System.out.println("执行时间:"+excTime+"s");