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
It returns a floating-point number, for compatibility with time(). If the input value cannot be represented as a valid time, either OverflowError or ValueError will be raised (which depends on whether the invalid value is caught by Python or the underlying C libraries). The earliest date for which it can generate a time is platform-dependent. ... Return the value (in fractional seconds) of a monotonic clock, i.e.
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-time-clock-method
Python | time.clock() method - GeeksforGeeks
December 8, 2022 - Syntax: time.clock() Parameter: No parameter is required. Return type: This method returns a float value which represents the current processor time in seconds.
🌐
Tutorialspoint
tutorialspoint.com › python › time_clock.htm
Python 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 ...
🌐
Python Module of the Week
pymotw.com › 3 › time
time — Clock Time
In this example, the formatted ctime() is printed along with the floating point values from time(), and clock() for each iteration through the loop. ... If you want to run the example on your system, you may have to add more cycles to the inner loop or work with a larger amount of data to actually see a difference in the times. $ python3 time_process_time.py Sun Dec 9 12:43:44 2018 : 1544377424.095 0.056 Sun Dec 9 12:43:44 2018 : 1544377424.423 0.675 Sun Dec 9 12:43:44 2018 : 1544377424.790 1.376 Sun Dec 9 12:43:45 2018 : 1544377425.108 1.997 Sun Dec 9 12:43:45 2018 : 1544377425.422 2.594
🌐
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 - Another important concept is the so-called system time, which is measured by the system clock. System time represents a computer system's notion of the passing of time. One should remember that the system clock could be modified by the operating system, thus modifying the system time. Python's time module provides various time-related functions.
🌐
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.
Find elsewhere
🌐
Python Module of the Week
pymotw.com › 2 › time
time – Functions for manipulating clock time - Python Module of the Week
March 9, 2008 - In this example, the formatted ctime() is printed along with the floating point values from time(), and clock() for each iteration through the loop. If you want to run the example on your system, you may have to add more cycles to the inner loop or work with a larger amount of data to actually see a difference. $ python time_clock.py Sun Mar 9 12:41:53 2008 : 1205080913.260 0.030 Sun Mar 9 12:41:53 2008 : 1205080913.682 0.440 Sun Mar 9 12:41:54 2008 : 1205080914.103 0.860 Sun Mar 9 12:41:54 2008 : 1205080914.518 1.270 Sun Mar 9 12:41:54 2008 : 1205080914.932 1.680
🌐
Reddit
reddit.com › r/learnpython › how does the time.clock() function work?
r/learnpython on Reddit: How does the time.clock() function work?
October 23, 2022 -

I pretty much understand the sleep() function of the time module - to create delays - and recently I discovered that there is another function of time that creates a stopwatch. My brother was trying to work with it, but it was not working. Maybe there actually is not a clock function in python.

if ClockFunctionExists == True: print("How can I implement it, and what are its parameters?") elif ClockFunctionExists == False: print("What can I do to create a stopwatch that runs in parallel to my program, measuring time for something to happen and not delaying the program by doing so") else: print("please respond")

🌐
MicroPython
docs.micropython.org › en › latest › library › time.html
time – time related functions — MicroPython latest documentation
Similar to ticks_ms() and ticks_us(), but with the highest possible resolution in the system. This is usually CPU clocks, and that’s why the function is named that way. But it doesn’t have to be a CPU clock, some other timing source available in a system (e.g. high-resolution timer) can be used instead.
🌐
Real Python
realpython.com › python-timer
Python Timer Functions: Three Ways to Monitor Your Code – Real Python
December 8, 2024 - In this step-by-step tutorial, you'll learn how to use Python timer functions to monitor how quickly your programs are running. You'll use classes, context managers, and decorators to measure your program's running time. You'll also learn the benefits of each method and which to use given the ...
🌐
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.
🌐
EDUCBA
educba.com › home › software development › software development tutorials › python tutorial › clock() in python
clock() in Python | Learn Various Representations of time in Python
March 30, 2023 - Clock() function in python is a part of the time module that encompasses several types of time representations. The time module in python covers a. CPU time; the system takes in executing a job in a multiprocessing environment where many jobs ...
Address   Unit no. 202, Jay Antariksh Bldg, Makwana Road, Marol, Andheri (East),, 400059, Mumbai
🌐
Tutorialspoint
tutorialspoint.com › python › time_time.htm
Python time time() Method
The Python time time() method returns the current UTC time. This return value is obtained as a floating point number expressed in seconds since the epoch. This method does not accept any arguments, hence, it always returns the current UTC time.
🌐
Dive into Python
diveintopython.org › home › learn python programming › date and time › time formats
Python Time Module: Time Formats, Sleep Function, Timeit with Examples
May 3, 2024 - In Python, the monotonic() function from the time module is used to obtain a monotonic clock, which is a clock that continually increases and is unaffected by system time adjustments.
🌐
Built In
builtin.com › articles › timing-functions-python
Timing Functions in Python: A Guide | Built In
To use this function, you can call time.perf_counter() before and after the code you want to time, subtracting the start time from the end time to get the elapsed time. One advantage of perf_counter() is that it’s based on a monotonic clock, which always increments and never goes backward.
🌐
GeeksforGeeks
geeksforgeeks.org › python-time-module
Python Time Module - GeeksforGeeks
August 13, 2024 - This module comes under Python’s standard utility modules. time.clock_gettime_ns() method of Time module is used to get the time (in nanoseconds) of the specified clock clk_id.
🌐
w3resource
w3resource.com › python-exercises › tkinter › python-tkinter-basic-exercise-14.php
Create a digital clock in Python using Tkinter
import tkinter as tk import time # Function to update the label text with the current time def update_time(): current_time = time.strftime('%H:%M:%S') clock_label.config(text=current_time) root.after(1000, update_time) # Update every 1000 milliseconds (1 second) # Create the main window root = tk.Tk() root.title("Digital Clock") # Create a label to display the time clock_label = tk.Label(root, text="", font=("Helvetica", 48)) clock_label.pack(padx=20, pady=20) # Start updating the time update_time() # Start the Tkinter event loop root.mainloop()
🌐
GeeksforGeeks
origin.geeksforgeeks.org › python › python-time-clock-method
Python | time.clock() method - GeeksforGeeks
December 8, 2022 - Syntax: time.clock() Parameter: No parameter is required. Return type: This method returns a float value which represents the current processor time in seconds.