You could use timeit.default_timer instead of time.time.
timeit.default_timer will choose the best timer (time.time, time.clock or time.perf_counter) for your system.
The resolution of the timer isn't unlimited; it goes up by small amounts periodically. If the two calls are close enough together, you will see a zero value. If you tried a large number of such calls, you would probably find that the difference is zero most of the time, and some number of microseconds the rest of the time, depending on your particular system's speed, hardware details, and kernel implementation.
참고자료 1 :
https://stackoverflow.com/questions/48196000/why-is-time-time-time-time-0-0
Why is time.time() - time.time() = 0.0?
Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:54:40) [MSC v.1900 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> >>> import tim...
stackoverflow.com
참고자료 2 :
https://stackoverflow.com/questions/33086519/why-time-time-gives-0-0
Why time.time() gives 0.0?
I have a python program defined by a function myFunc(m,n) Basically, the function contains two for loops. def myFunc(m, n) : for i in range(m) : for j in range(n) : # d...
stackoverflow.com
참고자료 3 : https://docs.python.org/ko/3/library/timeit.html
timeit — 작은 코드 조각의 실행 시간 측정 — Python 3.8.3 문서
timeit — 작은 코드 조각의 실행 시간 측정 소스 코드: Lib/timeit.py 이 모듈은 파이썬 코드의 작은 조각의 시간을 측정하는 간단한 방법을 제공합니다. 명령 줄 인터페이스뿐만 아니라 콜러블도 있�
docs.python.org
참고자료 4 : https://pymotw.com/2/timeit/
timeit – Time the execution of small bits of Python code. - Python Module of the Week
The timeit module provides a simple interface for determining the execution time of small bits of Python code. It uses a platform-specific time function to provide the most accurate time calculation possible. It reduces the impact of startup or shutdown co
pymotw.com
'Programming > Python' 카테고리의 다른 글
[Python] 파일명 추출, 디렉토리 경로 추출 (3) | 2020.11.20 |
---|---|
[Python] Python Schedule 모듈 이용하여 원하는 시간대에 프로그램 실행 시키기 (5) | 2020.11.02 |
[Python] Import 는 꼭 맨 윗줄에 써야하는가? (2) | 2020.04.17 |
[Python] 파일 읽고 쓰기 (0) | 2020.03.09 |
[Python] Anaconda 가상환경에서 spyder 실행하기 (Windows) (2) | 2020.02.07 |