Output time log for the code and find out time-consuming ones during execution. Please refer to the following Scripts and load it into PowerBuilder Application. A log with time interval regarding code will be generated while the object of_log(string arg) is called.
Please check the start time and end time of the code and find out time-consuming ones.
string is_LogFile="C:\debug\logservice.log"
string is_workdir="C:\debug\"
long il_LogFileHandle
IF NOT directoryexists(is_workdir) THEN
createdirectory(is_workdir)
END IF
il_LogFileHandle = FileOpen(is_LogFile,StreamMode!,write!,shared!,append!)
FileWrite(il_LogFileHandle,"~r~n~r~n")
of_log("==========Log service initialized=========")
public function integer of_log (string as_message);
IF FileExists(is_LogFile) THEN
IF FileLength(is_LogFile) > 2097152 THEN//2M
FileClose(il_logfilehandle)
FileCopy(is_LogFile,is_LogFile+".bak",true)
FileDelete(is_LogFile)
il_LogFileHandle = FileOpen(is_LogFile,StreamMode!,write!,shared!,append!)
END IF
END IF
as_message = "~r~n"+string(now(),"yyyy-mm-dd hh:mm:ss.fff") +as_message
FileWrite(il_logfilehandle,as_message)
return 1
end function

