ctime¶
Returns the number of CPU seconds used.
Synopsis¶
ctime( )
Return Value¶
The number of CPU seconds used so far by the program.
Example¶
The CPU time needed to compute
\[\textstyle\sum_{k=0}^{1,000,000} k\]
is obtained and printed. The time needed is, of course, machine dependent. The CPU time needed will also vary slightly from run to run on the same machine.
from __future__ import print_function
from pyimsl.math.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.448164