As of 3.3, time.clock() is deprecated, and it's suggested to use time.process_time() or time.perf_counter() instead.

Previously in 2.7, according to the time module docs:

time.clock()

On Unix, return the current processor time as a floating point number expressed in seconds. The precision, and in fact the very definition of the meaning of “processor time”, depends on that of the C function of the same name, but in any case, this is the function to use for benchmarking Python or timing algorithms.

On Windows, this function returns wall-clock seconds elapsed since the first call to this function, as a floating point number, based on the Win32 function QueryPerformanceCounter(). The resolution is typically better than one microsecond.

Additionally, there is the timeit module for benchmarking code snippets.

Answer from Jason Navarrete on Stack Overflow
🌐
Python
docs.python.org › 3 › library › time.html
time — Time access and conversions — Python 3.14.4 documentation
Added in version 3.3. ... Similar to clock_gettime() but return time as nanoseconds.
🌐
Tutorialspoint
tutorialspoint.com › python › time_clock.htm
Python 3 - time clock() Method
The Python time clock() method is used to get the current processor time. It is returned as a floating point number expressed in seconds. If the amount of time required to execute a program is to be calculated, the method needs to be invoked ...
🌐
GeeksforGeeks
geeksforgeeks.org › python-time-clock-method
Python | time.clock() method - GeeksforGeeks
December 8, 2022 - As, Most of the functions defined in time module call corresponding C library function. time.clock() method also call C library function of the same name to get the result. The precision of returned float value depends on the called C library function. Note: This method is deprecated since Python version 3.3 and will be removed in Python version 3.8.
🌐
Python Module of the Week
pymotw.com › 3 › time
time — Clock Time — PyMOTW 3
December 9, 2018 - $ python3 time_ctime.py The time is : Sun Dec 9 12:43:43 2018 15 secs from now : Sun Dec 9 12:43:58 2018 · Because time() looks at the system clock, and the system clock can be changed by the user or system services for synchronizing clocks across multiple computers, calling time() repeatedly may produce values that go forwards and backwards.
🌐
GitHub
github.com › wxWidgets › Phoenix › issues › 1510
time.clock() removed in Python3.8 replace with time.perf_counter() · Issue #1510 · wxWidgets/Phoenix
February 9, 2020 - The function time.clock() has been removed, after having been deprecated since Python 3.3: use time.perf_counter() or time.process_time() instead, depending on your requirements, to have well-defined behavior.
Author   Metallicow
🌐
GitHub
github.com › vispy › vispy › issues › 1659
Time.clock was deprecated in python 3.3, and was removed in python 3. 8 · Issue #1659 · vispy/vispy
July 9, 2019 - From the python 3.8 changelog:https://docs.python.org/3/whatsnew/3.8.html The function time.clock() has been removed, it was deprecated since Python 3.3: use time.perf_counter() or time.process_time() instead, depending on your requireme...
Author   ritobanrc
Find elsewhere
🌐
Python
docs.python.org › 3.3 › library › time.html
16.3. time — Time access and conversions — Python 3.3.7 documentation
The precision, and in fact the very definition of the meaning of “processor time”, depends on that of the C function of the same name, but in any case, this is the function to use for benchmarking Python or timing algorithms. On Windows, this function returns wall-clock seconds elapsed since the first call to this function, as a floating point number, based on the Win32 function QueryPerformanceCounter(). The resolution is typically better than one microsecond. Deprecated since version 3.3: The behaviour of this function depends on the platform: use perf_counter() or process_time() instead, depending on your requirements, to have a well defined behaviour.
🌐
Javatpoint
javatpoint.com › time-clock-method-in-python
Time clock() Method in Python - Javatpoint
Time clock() Method in Python with python, tutorial, tkinter, button, overview, entry, checkbutton, canvas, frame, environment set-up, first python program, operators, etc.
🌐
Delft Stack
delftstack.com › home › howto › python › time.clock python
clock() and time() Methods of the Time Module in Python | Delft Stack
March 11, 2025 - It measures the CPU time or process time in seconds. This method is particularly useful for profiling your Python code, allowing you to determine how much CPU time a specific part of your program is consuming.
🌐
Python Central
pythoncentral.io › measure-time-in-python-time-time-vs-time-clock
Measure Time in Python - time.time() vs time.clock() - Python Central
December 29, 2021 - Instead of dealing with the different behaviors of time.time() and time.clock() on different platforms, which is often error-prone, Python's timeit module provides a simple way for timing. Besides calling it directly from code, you can also call it from the command-line. ... [shell] % python -m timeit -n 10000 '[v for v in range(10000)]' 10000 loops, best of 3: 365 usec per loop % python -m timeit -n 10000 'map(lambda x: x^2, range(1000))' 10000 loops, best of 3: 145 usec per loop [/shell]
🌐
Python
bugs.python.org › issue31803
Issue 31803: time.clock() should emit a DeprecationWarning - Python tracker
October 17, 2017 - This issue tracker has been migrated to GitHub, and is currently read-only. For more information, see the GitHub FAQs in the Python's Developer Guide · This issue has been migrated to GitHub: https://github.com/python/cpython/issues/75984
🌐
Python Forum
python-forum.io › thread-33203.html
time.clock not functioning
I am using the following coding, from a text book, to compare two methods of measuring execution time for coding but time.clock is not recognised. I am on Windows 10 using Python 3.9.2 The coding is: import time def do_my_sum(xs): sum = 0 ...
🌐
Python Module of the Week
pymotw.com › 2 › time
time – Functions for manipulating clock time - Python Module of the Week
March 9, 2008 - Now available for Python 3! Buy the book! ... The time module exposes C library functions for manipulating dates and times. Since it is tied to the underlying C implementation, some details (such as the start of the epoch and maximum date value supported) are platform-specific.
🌐
W3Schools
w3schools.com › python › ref_module_time.asp
Python time Module
Python Examples Python Compiler Python Exercises Python Quiz Python Challenges Python Practice Problems Python Server Python Syllabus Python Study Plan Python Interview Q&A Python Bootcamp Python Certificate Python Training ... import time start = time.time() print(f'Start time: {start}') time.sleep(1) end = time.time() print(f'Elapsed: {end - start:.2f} seconds') Try it Yourself »
🌐
Programiz
programiz.com › python-programming › time
Python time Module (with Examples)
The time.ctime() function in Python takes seconds passed since epoch as an argument and returns a string representing local time.
🌐
Python
docs.python.org › 3.0 › library › time.html
time — Time access and conversions — Python v3.0.1 documentation
The precision, and in fact the very definition of the meaning of “processor time”, depends on that of the C function of the same name, but in any case, this is the function to use for benchmarking Python or timing algorithms. On Windows, this function returns wall-clock seconds elapsed since the first call to this function, as a floating point number, based on the Win32 function QueryPerformanceCounter.
🌐
Python
bugs.python.org › issue14309
Issue 14309: Deprecate time.clock() - Python tracker
This issue tracker has been migrated to GitHub, and is currently read-only. For more information, see the GitHub FAQs in the Python's Developer Guide · This issue has been migrated to GitHub: https://github.com/python/cpython/issues/58517