To record the running time of the program you can take advantage of the number of milliseconds in the UNIX system for the 1970.1.1 to the present time, and this timestamp is easily completed.
The method is to save a variable at the beginning of the program, and then save a variable at the end of the program, and then subtract the timestamp from the start of the program.
Python's method of taking this timestamp is to use Time.time () after introducing the time class, which can be taken out. The System.currenttimemillis () in Java.
Since Python needs the exact time of the current few months, like Java, this constant is involved, so in "Python" using the current time, random numbers to produce a unique number (click on the Open link) is not introduced.
The specific method is as follows, taking a 100,000,000-, 100 million-cycle time as an example
Import time;
Time_start=time.time () #time. Time () is the number of milliseconds from 1970.1.1 to the current
i=0;
While i<100000000:
i+=1
time_end=time.time (), #time. Time () is the number of milliseconds from 1970.1.1 to the current date
print Time_end-time_ Start,
print "s"
The results of the operation are as follows:
The result of Time_end-time_start subtraction is directly a fraction of a second.
So the final output is then filled with a unit, S, second.