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 253 views
1 answer 92 views
92 views asked Mar 14, 2025 by avibootz
1 answer 217 views
217 views asked Feb 22, 2022 by avibootz
1 answer 261 views
1 answer 202 views
...