How to measure the range() function time in nanoseconds with Python

1 Answer

0 votes
import time

start = time.perf_counter_ns()
for x in range(10000000):
    pass
stop = time.perf_counter_ns()
 
print(stop - start, "nanoseconds")
 
 
'''
run:
 
385241337 nanoseconds
 
'''

 



answered Aug 4, 2024 by avibootz

Related questions

2 answers 254 views
1 answer 93 views
93 views asked Mar 14, 2025 by avibootz
1 answer 218 views
218 views asked Feb 22, 2022 by avibootz
1 answer 262 views
1 answer 202 views
...