mirror of
https://github.com/rasbt/python_reference.git
synced 2024-11-27 22:11:13 +00:00
19 lines
327 B
Python
19 lines
327 B
Python
|
# sr 10/29/13
|
||
|
# Calculates elapsed CPU time in seconds as float.
|
||
|
|
||
|
import time
|
||
|
|
||
|
start_time = time.clock()
|
||
|
|
||
|
i = 0
|
||
|
while i < 10000000:
|
||
|
i += 1
|
||
|
|
||
|
elapsed_time = time.clock() - start_time
|
||
|
print "Time elapsed: {} seconds".format(elapsed_time)
|
||
|
|
||
|
# prints "Time elapsed: 1.06 seconds"
|
||
|
# on 4 x 2.80 Ghz Intel Xeon, 6 Gb RAM
|
||
|
|
||
|
|