得到某一段代码所运行的时间。
得到:
long startTime = System.nanoTime(); //获取开始时间
List<Equipment> tempEquipList = equipmentInfoDao.getFunctionPlaceList();
if(tempEquipList != null && tempEquipList.size() > 0){
for(Equipment equipment:tempEquipList){
if("2".equals(equipment.getRemark()))
feederLength.setLStation(equipment.getG3e_id()); // 变电站
if("3".equals(equipment.getRemark()))
feederLength.setLFeeder(equipment.getG3e_id()); // 馈线
}
}
long endTime=System.nanoTime(); //获取结束时间
System.out.println("程序运行时间: "+(endTime-startTime)+"ns");
得到:
程序运行时间: 85198258ns