Using the time module 1.1 * 1.2 * ... * 10.1 (increase by 0.1) and 1 * 2 * ... * How do I print out the time it takes to perform 100 (increase by 1)?

Asked 1 years ago, Updated 1 years ago, 114 views

Using the time module 1.1 * 1.2 * ... * 10.1 (increase by 0.1) and 1 * 2 * ... * How do I print out the time it takes to perform 100 (increase by 1)?

python time time-module

2022-09-22 15:31

1 Answers

You can use the timeit module.

In [1]: import timeit

In [2]: timeit.Timer('for i in range(10000):i += i').timeit(1)
Out[2]: 0.000613681999993787


2022-09-22 15:31

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.