As an example, you can use the code below:
import timeit def string_generator(size): return (size/8) * "ABCDEFGH" if __name__ == "__main__":
Results:
0.00784516334534 [0.0009770393371582031, 0.00036597251892089844, 0.00037407875061035156] 0.414484977722
The unit for the results is the second. Additional examples exist on the python website. enter the link here
Also you can use ipython. The same example is given below.
In [25]: %timeit "-".join(str(n) for n in range(100))
Result:
10000 loops, best of 3: 22.9 µs per loop
As you can see, the block takes the second place.
source share