let me start by saying a few things about the pits I ran into, the production problems I ran into, the fact that I was scheduling Python scripts to execute and monitoring the process, and that Python scripts took much longer to execute than the Python scripts themselves.
monitor python script execution time is 36 hours , while python script statistics their execution time time is 4 hours or so.
problem after the first thought was that there was a problem with Linux, looking for various logs did not find any exceptions.
is then thought of in python as py2neo writing data asynchronously, blocking the execution of the process. Finally, the problem was identified: the python script USES time.clock(), which counts the CPU execution time, not the program execution time. Next, compare several python time statistics:
method 1:
import datetime
starttime = datetime.datetime.now()
#long running
#do something other
endtime = datetime.datetime.now()
print (endtime - starttime).seconds
datetime. Datetime. Now () gets the current date, which is execution time after the execution of the program.
method 2:
start = time.time()
#long running
#do something other
end = time.time()
print end-start
time.time() gets the current time, in seconds, since epoch. If the system clock provides them, fractions of seconds may exist. So this is going to return a floating point type. This is also the program execution time .
method 3:
start = time.clock()
#long running
#do something other
end = time.clock()
print end-start
time.clock() returns the CPU time since the program started or the first time it was called clock(). This has as much precision as the system records. It also returns a floating point type. What you get here is CPU execution time . Note: program execution time = CPU time + IO time + sleep or wait time
Read More:
- Time, strftime and strptime in Python
- Translate() and maketrans() methods of string in Python
- Several implementation methods of Python timing task
- Run Python file for the first time with eclipse / pydev: “UTF-8 ‘codec can’t decode byte 0xc4 in position
- The time of the time database displayed by the front end is inconsistent
- Calculation method of RMSE and MAPE in MATLAB
- How to get the current time in java time string
- After switching the tidb database, an error could not commit JDBC transaction appears from time to time
- When calling time module – time / datetime in wxPython, an error is reported. Valueerror: unknown locale: zh cn
- Can’t find Python executable “D:\python3\python.exe”, you can set the PYTHON env variable.
- Several methods of executing multiple commands in Linux shell
- Common attributes and methods of list and map in Dar
- Methods of modifying index and columns names by dataframe in pandas
- Common errors and modification methods of findbug
- Several common methods of inserting pictures into latex documents
- ‘Conversion failed when converting date and/or time from character string.DB-Lib error message 241,
- Edge detection: two methods
- Three methods of how to remove the flashback of running result box in VS
- No supported authentication methods available
- Three methods of JavaScript jump to new page