-
[Python] 소요시간 측정방법Engineering WIKI/Python 2020. 12. 9. 19:28
import datetime start_time = datetime.datetime.now() # ( 측정을 하고자 하는 코드 ) end_time = datetime.datetime.now() elapsed_time = end_time - start_time
여기서 얻은 elapsed_time을 활용하여 millesecond 단위, microsecond 단위, second 단위로 결과 값을 얻을 수 있다.
microsecond 단위micro_elapsed_time = elapsed_time.microseconds
millisecond 단위 ( 1 millisecond == 1000 microsecond )
ms_elapsed_time = elapsed_time.microseconds / 1000
second 단위
sec_elapsed_time = elapsed_time.seconds
출처: https://somjang.tistory.com/entry/Python-datetime을-활용하여-코드-소요시간-측정하기 [솜씨좋은장씨]'Engineering WIKI > Python' 카테고리의 다른 글
[Python] FastAPI 사용법 (0) 2021.04.13 [Python] One-line Tree in Python (0) 2021.02.21 [Python] pyinstaller 실행파일 생성 (0) 2021.02.21 Pandas 텍스트(txt) 파일 불러오기 및 저장하기 (0) 2021.02.03 [Python] Coding Test Tip (0) 2020.12.09 [Python] zip(*iterable) (0) 2020.11.11 [Python] f-string (0) 2020.04.18 [Python] 리스트 문자열 합치기 .join() (0) 2020.03.29