Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
QM hanging/frozen
#6
This is not as fast as LogFileFast, but much faster than LogFile.

Function LogFileFaster
Code:
Copy      Help
;/
function str'text

;Writes text to file "$my qm$\LogFileFaster.txt". Appends newline.
;Deletes old file when called first time in current QM session.
;To change file, edit this function. Or execute this when QM starts, before calling this function first time: str+ g_LFF_File="C:\...\your file.txt"
;Faster than LogFile which opens and closes the file each time. This function opens the file when called first time, and it is closed when QM exits or opens another QM file.

;Tested speed:
;When called very frequently - 9 mcs with cold CPU, 1 mcs with warm CPU.
;When called after some time - 30-60 mcs with cold CPU, 10-30 mcs with warm CPU.
;LogFile speed is > 100 mcs.


opt noerrorshere 1
str+ g_LFF_File
__HFile+ __LFF_HFile
if !__LFF_HFile
,lock
,if !__LFF_HFile
,,if(!g_LFF_File.len) g_LFF_File="$my qm$\LogFileFaster.txt"
,,__LFF_HFile.Create(g_LFF_File CREATE_ALWAYS GENERIC_WRITE FILE_SHARE_READ) ;;error if fails
,lock-

text+"[]"
if(!WriteFile(__LFF_HFile text text.len &_i 0)) end "failed" 8|16 ;;warning if fails

;WriteFile does not write to disk immediately. It writes to a file buffer in memory, which is regularly written to disk, maybe every several seconds.


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)