chrono 사용

 

	// 시간 측정 시작
	system_clock::time_point start = system_clock::now();

	int result = 0;
	int plus = 0;
	for (int i = M; plus < N + 1; i)
	{
		plus += M;
		result += plus;
	}
	// 시간 측정 종료
	system_clock::time_point end = system_clock::now();

	// 시간 계산
	nanoseconds nano = end - start;
	microseconds micro = duration_cast<microseconds>(end - start);
	milliseconds mill = duration_cast<milliseconds>(end - start);
	seconds sec = duration_cast<seconds>(end - start);
	minutes min = duration_cast<minutes>(end - start);
	hours hour = duration_cast<hours>(end - start);

	cout << "걸린 시간 : " << nano.count() << " nanoseconds" << endl;
	cout << "걸린 시간 : " << micro.count() << " microseconds" << endl;
	cout << "걸린 시간 : " << mill.count() << " milliseconds" << endl;
	cout << "걸린 시간 : " << sec.count() << " seconds" << endl;
	cout << "걸린 시간 : " << min.count() << " minutes" << endl;
	cout << "걸린 시간 : " << hour.count() << " hour" << endl;

'Language > C++' 카테고리의 다른 글

C++ 시간 재기  (0) 2022.03.14
Mat 형식 Binary file로 저장 및 Binary file 불러오기  (0) 2022.02.22
opencv vector to Mat  (0) 2021.12.23
Image to Base64, Base64 to Image  (0) 2021.11.18
파일 랜덤 추출  (0) 2021.10.14

+ Recent posts