Starting with Python 3.3 you now have access to a high resolution time counter (nanoseconds and better).
High resolution time measurement (Python)
Gribouillis commented: very nice +14
TrustyTony commented: Good info +12
''' time_high_resolution_counter.py
measure elapsed time of a Python calculation
time.perf_counter() is new in Python 3.3
'''
import time
# returned value is in fractional seconds
start = time.perf_counter()
# let's time this calculation
y = 2**0.5
end = time.perf_counter()
elapsed = end - start
print("elapsed time = {:.12f} seconds".format(elapsed))
''' result (on an intel core i5 computer) ...
elapsed time = 0.000000410520 seconds
'''
ddanbe 2,724 Professional Procrastinator Featured Poster
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.