Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,895 questions

51,826 answers

573 users

How to get clock info for information about the clock in python

1 Answer

0 votes
import time
import textwrap     

the_clocks = [         
    ('clock', time.clock),         
    ('monotonic', time.monotonic),
    ('perf_counter', time.perf_counter),         
    ('process_time', time.process_time),         
    ('time', time.time),]
    

for clock_name, function in the_clocks:         
    print(textwrap.dedent('''{name}:             
            adjustable    : {info.adjustable}             
            implementation: {info.implementation}             
            monotonic     : {info.monotonic}             
            resolution    : {info.resolution}             
            current       : {current}''').format(name=clock_name, info=time.get_clock_info(clock_name), current=function())
         )
         
         
'''
run:

clock:             
            adjustable    : False             
            implementation: clock()             
            monotonic     : True             
            resolution    : 1e-06             
            current       : 0.042364
monotonic:             
            adjustable    : False             
            implementation: clock_gettime(CLOCK_MONOTONIC)             
            monotonic     : True             
            resolution    : 1e-09             
            current       : 4486722.66659043
perf_counter:             
            adjustable    : False             
            implementation: clock_gettime(CLOCK_MONOTONIC)             
            monotonic     : True             
            resolution    : 1e-09             
            current       : 4486722.666622312
process_time:             
            adjustable    : False             
            implementation: clock_gettime(CLOCK_PROCESS_CPUTIME_ID)             
            monotonic     : True             
            resolution    : 1e-09             
            current       : 0.042480553000000004
time:             
            adjustable    : True             
            implementation: clock_gettime(CLOCK_REALTIME)             
            monotonic     : False             
            resolution    : 1e-09             
            current       : 1559417939.157021
            
'''

 



answered Jun 1, 2019 by avibootz

Related questions

...