728x90
반응형

 

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

 

728x90
반응형