ctime¶
Returns the number of CPU seconds used.
Synopsis¶
ctime( )
Return Value¶
The number of CPU seconds used by the program.
Example¶
The CPU time needed to compute
\[\sum_{k=0}^{1,000,000} k\]
is obtained and printed. The time needed is machine dependent. The CPU time needed varies slightly from run to run on the same machine.
from __future__ import print_function
from pyimsl.stat.ctime import ctime
sum = 0
for k in range(1, 1000001):
sum += k
time = ctime()
print("sum = ", sum)
print("time = ", time)
Output¶
sum = 500000500000
time = 0.44075699999999995