time.perf_counter()
time.perf_counter() is a Python function in the Time Module category. Returns a high-resolution performance counter (best for measuring intervals). The syntax is time.perf_counter(). Returns: Float seconds (high precision). A typical example: start = time.perf_counter()
# Do some work
end = time.perf_counter()
print(f"Elapsed: {end-start:.3f}s"). A close sibling is time.time(), which returns the current Unix timestamp (seconds since epoch). A close sibling is time.sleep(), which suspends execution for the given number of seconds (may be fractional). A close sibling is time.gmtime(), which converts a timestamp to a time.struct_time in UTC. A close sibling is time.localtime(), which converts a timestamp to a time.struct_time in local time. More about this category: Time access and conversions — time, sleep, strftime, perf_counter. For a broader walkthrough, read the Time Module guide. Related Time Module entries: time.time(), time.sleep(), time.gmtime(), time.localtime(), time.strftime(), time.strptime(). This page is part of the free Python Reference documentation covering 978+ functions, methods, and modules with examples and parameter details.