Python | time.clock_settime_ns() method
Last Updated :
17 Sep, 2019
time.clock_settime_ns()
method of Time module is used to set the time (in nanoseconds) of the specified clock clk_id
. Basically, clk_id is a integer value which represents the id of the clock. This method is similar to time.clock_settime()
method which is used to set time of the specified clock clk_id but in fractional seconds.
Syntax: time.clock_settime_ns(clk_id, nanoseconds)
Parameters:
clk_id: A clk_id constant or an integer value representing clk_id of the clock.
Return type: This method does not return any value.
Code: Use of time.clock_settime_ns()
method
import time
clk_id = time.CLOCK_REALTIME
t = time.clock_gettime_ns(clk_id)
print ( "Current value of system-wide real-time clock: % d nanoseconds" % t)
nanosecs = 10000000
time.clock_settime(clk_id, nanosecs)
print ( "\nTime modified" )
t = time.clock_gettime_ns(clk_id)
print ( "\nCurrent value of system-wide real-time clock: % d nanoseconds" % t)
|
Output:
Current value of system-wide real-time clock: 1568621304462590132 nanoseconds
Time modified
Current value of system-wide real-time clock: 10000000000180111 nanoseconds
Reference: https://docs.python.org/3/library/time.html#time.clock_settime_ns
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...