天天看點

測試方法執行時間

@Test
	public void test(){
		Long begin = System.currentTimeMillis();
		t();//方法
		Long end = System.currentTimeMillis();
		double timeDouble= Double.parseDouble(Long.toString(end-begin));
		System.out.println("該方法執行時間為" + timeDouble+ "毫秒,即" + timeDouble/(double)1000 + "秒");
		int	minute = (int)(timeDouble)/(60*1000);
		int second = (int)(timeDouble)%(60*1000)/1000;
		System.out.println("轉化後耗時為:" + minute + "分" + second +"秒");
		//(int)(timeDouble/(24*60*60*1000));天數
	    //(int)(timeDouble%(24*60*60*1000))/(60*60*1000);小時數
	}