Profiling removing many files and folders
;------------------------------------------------------------------------------------------------------------------------------------------
; Removing foldertree with many files.
; Profiling Performance Test.
;
; (c)Detlev Dalitz.20091215.
;------------------------------------------------------------------------------------------------------------------------------------------

BoxOpen ("Profiling Performance Test: Removing foldertree with many files", "Please wait ...")

IntControl (51, 16384, 0, 0, 0)
; IntControl (51, p1, 0, 0, 0) ; Specifies flags for CreateProcess.
; Value  Priority                     Description
;    32  NORMAL_PRIORITY_CLASS        Indicates a normal process with no special scheduling needs.
;    64  IDLE_PRIORITY_CLASS          Indicates a process whose threads run only when the system is idle and are preempted by the threads of any process running in a higher priority class. An example is a screen saver. The idle priority class is inherited by child processes.
;   128  HIGH_PRIORITY_CLASS          Indicates a process that performs time-critical tasks that must be executed immediately for it to run correctly. The threads of a high-priority class process preempt the threads of normal or idle priority class processes. An example is the Task List, which must respond quickly when called by the user, regardless of the load on the operating system. Use extreme care when using the high-priority class, because a high-priority class CPU-bound application can use nearly all available cycles.
;   256  REALTIME_PRIORITY_CLASS      Indicates a process that has the highest possible priority. The threads of a real-time priority class process preempt the threads of all other processes, including operating system processes performing important tasks. For example, a real-time process that executes for more than a very brief interval can cause disk caches not to flush or cause the mouse to be unresponsive.
; 16384  BELOW_NORMAL_PRIORITY_CLASS  Windows NT and Windows Me/98/95: This value is not supported. Indicates a process that has priority above IDLE_PRIORITY_CLASS but below NORMAL_PRIORITY_CLASS.
; 32768  ABOVE_NORMAL_PRIORITY_CLASS  Windows NT and Windows Me/98/95: This value is not supported. Indicates a process that has priority above NORMAL_PRIORITY_CLASS but below HIGH_PRIORITY_CLASS.

strCmdExe = Environment ("COMSPEC")

strCmdPar1 = '/C DEL /S /Q /F "W:\FILETEST1\*.*" >NUL: 2>&1 && RD /S /Q "W:\FILETEST1\" >NUL: 2>&1'
strCmdPar2 = '/C RD /S /Q "W:\FILETEST2\" >NUL: 2>&1'

BoxText ("Test 1 is running ...")
intTicks0 = GetTickCount ()
RunHideWait (strCmdExe, strCmdPar1)
intTicks1 = GetTickCount () - intTicks0
BoxText ("Test 1 is ready.")

BoxText ("Test 2 is running ...")
intTicks0 = GetTickCount ()
RunHideWait (strCmdExe, strCmdPar2)
intTicks2 = GetTickCount () - intTicks0
BoxText ("Test 2 is ready.")

BoxText ("Calculation is running ...")
Decimals (0)
intTicksMax = Max (intTicks1, intTicks2)
intPct1 = 100.0 * intTicks1 / intTicksMax
intPct2 = 100.0 * intTicks2 / intTicksMax
BoxText ("Calculation is ready.")

BoxText ("Output preparing is running ...")
strMsgText = strCmdPar1 : @TAB : ": " : intTicks1 : " ticks" : @TAB : intPct1 : " pct" : @CRLF
strMsgText = strMsgText : strCmdPar2 : @TAB : ": " : intTicks2 : " ticks" : @TAB : intPct2 : " pct" : @CRLF

strFileOut = ItemRemove (-1, IntControl (1004, 0, 0, 0, 0), ".") : ".txt"
FilePut (strFileOut, strMsgText)
Run (strFileOut, "")

BoxText ("Output is ready.")
BoxShut ()
Exit

; Deleting 110000 Files, 31.726.401 Bytes, in one folder, no subfolders.
; /C DEL /S /Q /F "W:\FILETEST1\*.*" >NUL: 2>&1 && RD "W:\FILETEST1\" >NUL: 2>&1   : 92750 ticks   100.00 pct
; /C RD /S /Q "W:\FILETEST2\" >NUL: 2>&1   : 81375 ticks   87.74 pct