Code: Select all
DIR "%~3" /W | FIND "ill"
Above is the command which normally takes perhaps 50 mSec, but on every eighth instance it takes 4000 mSec,
and after competing a run with 31 such instances over a 136 second period,
The Windows Task Manage Resources shows under "CPU" that 19 off CMD.EXE PIDS were "terminated"
( there were perhaps 31 terminations, but the instances are progressively grayed out and vanished. )
For some reason the same code sequence runs 7 times without faltering, and on the eight run it chokes and runs out of breath.
If no arguments were given when my script is launched, it calls itself with a representative set of arguments that stipulate :-
The number of copies of a files to place in each of a sequence of paths ( e.g. "E:\Test\Fill\A" "E:\Test\Fill\B" "E:\Test\Fill\C" )
The intention was (and will be) to place one copy of the original file in each path,
and to repeat until each path has received the designated number of copies.
A lot of the complexity has been stripped away below to simplify analysis of the problem.
I have found a way to reduce the frequency with which I invoke DIR and this seems to work-a-round my problem,
BUT I WOULD APPRECIATE an explanation of this problem and if there is a better way that to avoid these 4 second periods of death.
This is my simplified script
Code: Select all
@echo off & SETLOCAL EnableDelayedExpansion
SET "TINY=500K.BIN"
IF "%1"=="" (CALL "%~f0" 1 "%TINY%" "E:\Test\Fill\A" "E:\Test\Fill\B" "E:\Test\Fill\C") & GOTO :EOF
ECHO #### %~t0 ##### %DATE% %TIME% #####################################
SET /A N=10 & SET /A P=1
SET "T1=%TIME%
CALL :SHOW_FILES %* & SET /A P+=1
CALL :SHOW_FILES %* & SET /A P+=1
CALL :SHOW_FILES %* & SET /A P+=1
CALL :SHOW_FILES_PLUS %* & SET /A P+=11
CALL :SHOW_FILES %* & SET /A P+=1
CALL :SHOW_FILES %* & SET /A P+=1
GOTO :EOF
:SHOW_FILES_PLUS
IF NOT EXIST "%~3\" GOTO :NEXT_SHOW_FILE
DIR "%~3" /W | FIND "ill"
CALL :SHOW_TIME %T1% "##--@--%N%--##" %P% & SET /A N+=1
:SHOW_FILES
ECHO -------------- %TIME% -- START : Call %0 [%*] -----
:SHOW_FILES_LOOP
IF NOT EXIST "%~3\" GOTO :NEXT_SHOW_FILE
DIR "%~3" /W | FIND "ill"
CALL :SHOW_TIME %T1% "##-----%N%--##" %P% & SET /A N+=1
DIR "%~3" /W | FIND "ill"
CALL :SHOW_TIME %T1% "##--A--%N%--##" %P% & SET /A N+=1
DIR "%~3" /W | FIND "ill"
CALL :SHOW_TIME %T1% "##-----%N%--##" %P% & SET /A N+=1
DIR "%~3" /W | FIND "ill"
CALL :SHOW_TIME %T1% "##--B--%N%--##" %P% & SET /A N+=1
DIR "%~3" /W | FIND "ill"
CALL :SHOW_TIME %T1% "##-----%N%--##" %P% & SET /A N+=1
DIR "%~3" /W | FIND "ill"
CALL :SHOW_TIME %T1% "##--C--%N%--##" %P% & SET /A N+=1
DIR "%~3" /W | FIND "ill"
CALL :SHOW_TIME %T1% "##-----%N%--##" %P% & SET /A N+=1
DIR "%~3" /W | FIND "ill"
CALL :SHOW_TIME %T1% "##--D--%N%--##" %P% & SET /A N+=1
DIR "%~3" /W | FIND "ill"
CALL :SHOW_TIME %T1% "##-----%N%--##" %P% & SET /A N+=1
DIR "%~3" /W | FIND "ill"
CALL :SHOW_TIME %T1% "##--E--%N%--##" %P% & SET /A N+=1
DIR "%~3" /W | FIND "ill"
CALL :SHOW_TIME %T1% "##-----%N%--##" %P% & SET /A N+=1
DIR "%~3" /W | FIND "ill"
CALL :SHOW_TIME %T1% "##--F--%N%--##" %P% & SET /A N+=1
DIR "%~3" /W | FIND "ill"
CALL :SHOW_TIME %T1% "##-----%N%--##" %P% & SET /A N+=1
DIR "%~3" /W | FIND "ill"
CALL :SHOW_TIME %T1% "##--G--%N%--##" %P% & SET /A N+=1
ECHO(
:NEXT_SHOW_FILE
SHIFT
IF "%3" NEQ "" GOTO :SHOW_FILES_LOOP
ECHO -------------- %TIME% -- END of : Call %0 [%*] -----
ECHO(
GOTO :EOF
:SHOW_TIME
SET "TD=%TIME%"
CALL :T_DIFF %T1% %TD%
SET /A L_NUM += 1
SET "BIG=" & IF %DIFF% GEQ 1000 SET "BIG=%DIFF% Above 1000"
ECHO %L_NUM% %TIME_DIFF% "%~2" "%~3" "%~4" %BIG%
SET "T1=%TD%"
GOTO :EOF
:T_DIFF
FOR /F "tokens=1-4 delims=:." %%d in ("%1") do SET /A mS1=%%d*360000+1%%e*6000+1%%f*100+1%%g-610100
FOR /F "tokens=1-4 delims=:." %%d in ("%2") do SET /A mS2=%%d*360000+1%%e*6000+1%%f*100+1%%g-610100
REM Add 5 mSec extra to avoid subsequent "divide by zero errors"and to +/- split digitization error
SET /A DIFF=(((%mS2%-%mS1%)*10)+5)
SET "TIME_DIFF=%TD%-%T1% = %ms2%-%ms1% mSec = %DIFF% mSec"
GOTO :EOF
This is the beginning of the script output
Code: Select all
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Users\Alan>cd /d E:\Test\Fill
E:\Test\Fill>#
#### 09/01/2014 19:45 ##### 09/01/2014 19:45:50.75 #####################################
-------------- 19:45:50.76 -- START : Call :SHOW_FILES [1 "500K.BIN" "E:\Test\Fill\A" "E:\Test\Fill\B" "E:\Test\Fill\C"] -----
Directory of E:\Test\Fill\A
1 19:45:50.80-19:45:50.75 = 7115080-7115075 mSec = 55 mSec "##-----10--##" "1" ""
Directory of E:\Test\Fill\A
2 19:45:50.84-19:45:50.80 = 7115084-7115080 mSec = 45 mSec "##--A--11--##" "1" ""
Directory of E:\Test\Fill\A
3 19:45:50.88-19:45:50.84 = 7115088-7115084 mSec = 45 mSec "##-----12--##" "1" ""
Directory of E:\Test\Fill\A
4 19:45:50.92-19:45:50.88 = 7115092-7115088 mSec = 45 mSec "##--B--13--##" "1" ""
Directory of E:\Test\Fill\A
5 19:45:50.97-19:45:50.92 = 7115097-7115092 mSec = 55 mSec "##-----14--##" "1" ""
Directory of E:\Test\Fill\A
6 19:45:51.00-19:45:50.97 = 7115100-7115097 mSec = 35 mSec "##--C--15--##" "1" ""
Directory of E:\Test\Fill\A
7 19:45:51.04-19:45:51.00 = 7115104-7115100 mSec = 45 mSec "##-----16--##" "1" ""
Directory of E:\Test\Fill\A
8 19:45:51.08-19:45:51.04 = 7115108-7115104 mSec = 45 mSec "##--D--17--##" "1" ""
Directory of E:\Test\Fill\A
9 19:45:55.30-19:45:51.08 = 7115530-7115108 mSec = 4225 mSec "##-----18--##" "1" "" 4225 Above 1000
Directory of E:\Test\Fill\A
10 19:45:55.38-19:45:55.30 = 7115538-7115530 mSec = 85 mSec "##--E--19--##" "1" ""
Directory of E:\Test\Fill\A
11 19:45:55.42-19:45:55.38 = 7115542-7115538 mSec = 45 mSec "##-----20--##" "1" ""
Directory of E:\Test\Fill\A
12 19:45:55.46-19:45:55.42 = 7115546-7115542 mSec = 45 mSec "##--F--21--##" "1" ""
Directory of E:\Test\Fill\A
13 19:45:55.50-19:45:55.46 = 7115550-7115546 mSec = 45 mSec "##-----22--##" "1" ""
Directory of E:\Test\Fill\A
14 19:45:55.54-19:45:55.50 = 7115554-7115550 mSec = 45 mSec "##--G--23--##" "1" ""
Directory of E:\Test\Fill\B
15 19:45:55.59-19:45:55.54 = 7115559-7115554 mSec = 55 mSec "##-----24--##" "1" ""
Directory of E:\Test\Fill\B
16 19:45:55.64-19:45:55.59 = 7115564-7115559 mSec = 55 mSec "##--A--25--##" "1" ""
Directory of E:\Test\Fill\B
17 19:45:59.86-19:45:55.64 = 7115986-7115564 mSec = 4225 mSec "##-----26--##" "1" "" 4225 Above 1000
Directory of E:\Test\Fill\B
18 19:45:59.92-19:45:59.86 = 7115992-7115986 mSec = 65 mSec "##--B--27--##" "1" ""
When I FIND each occurrence of "Above" in the above output I get :-
Code: Select all
E:\Test\Fill>find "Above" < results.txt
9 19:45:55.30-19:45:51.08 = 7115530-7115108 mSec = 4225 mSec "##-----18--##" "1" "" 4225 Above 1000
17 19:45:59.86-19:45:55.64 = 7115986-7115564 mSec = 4225 mSec "##-----26--##" "1" "" 4225 Above 1000
25 19:46:04.41-19:46:00.26 = 7116441-7116026 mSec = 4155 mSec "##-----34--##" "1" "" 4155 Above 1000
33 19:46:08.96-19:46:04.78 = 7116896-7116478 mSec = 4185 mSec "##-----42--##" "1" "" 4185 Above 1000
41 19:46:13.51-19:46:09.28 = 7117351-7116928 mSec = 4235 mSec "##-----50--##" "1" "" 4235 Above 1000
49 19:46:18.02-19:46:14.12 = 7117802-7117412 mSec = 3905 mSec "##-----58--##" "2" "" 3905 Above 1000
57 19:46:22.59-19:46:18.78 = 7118259-7117878 mSec = 3815 mSec "##-----66--##" "2" "" 3815 Above 1000
65 19:46:27.13-19:46:23.29 = 7118713-7118329 mSec = 3845 mSec "##-----74--##" "2" "" 3845 Above 1000
73 19:46:31.64-19:46:27.79 = 7119164-7118779 mSec = 3855 mSec "##-----82--##" "2" "" 3855 Above 1000
81 19:46:36.15-19:46:32.30 = 7119615-7119230 mSec = 3855 mSec "##-----90--##" "2" "" 3855 Above 1000
89 19:46:40.65-19:46:36.80 = 7120065-7119680 mSec = 3855 mSec "##-----98--##" "3" "" 3855 Above 1000
97 19:46:45.20-19:46:41.43 = 7120520-7120143 mSec = 3775 mSec "##-----106--##" "3" "" 3775 Above 1000
105 19:46:49.75-19:46:45.94 = 7120975-7120594 mSec = 3815 mSec "##-----114--##" "3" "" 3815 Above 1000
113 19:46:54.30-19:46:50.52 = 7121430-7121052 mSec = 3785 mSec "##-----122--##" "3" "" 3785 Above 1000
121 19:46:58.87-19:46:55.05 = 7121887-7121505 mSec = 3825 mSec "##-----130--##" "3" "" 3825 Above 1000
129 19:47:03.44-19:46:59.73 = 7122344-7121973 mSec = 3715 mSec "##--A--138--##" "4" "" 3715 Above 1000
137 19:47:07.94-19:47:04.24 = 7122794-7122424 mSec = 3705 mSec "##--E--146--##" "4" "" 3705 Above 1000
145 19:47:12.45-19:47:08.73 = 7123245-7122873 mSec = 3725 mSec "##--B--154--##" "4" "" 3725 Above 1000
153 19:47:16.95-19:47:13.23 = 7123695-7123323 mSec = 3725 mSec "##--F--162--##" "4" "" 3725 Above 1000
161 19:47:21.45-19:47:17.84 = 7124145-7123784 mSec = 3615 mSec "##--C--170--##" "4" "" 3615 Above 1000
169 19:47:25.95-19:47:22.36 = 7124595-7124236 mSec = 3595 mSec "##--G--178--##" "4" "" 3595 Above 1000
177 19:47:30.52-19:47:26.92 = 7125052-7124692 mSec = 3605 mSec "##--D--186--##" "15" "" 3605 Above 1000
185 19:47:35.07-19:47:31.49 = 7125507-7125149 mSec = 3585 mSec "##--A--194--##" "15" "" 3585 Above 1000
193 19:47:39.62-19:47:36.26 = 7125962-7125626 mSec = 3365 mSec "##--E--202--##" "15" "" 3365 Above 1000
201 19:47:44.17-19:47:40.78 = 7126417-7126078 mSec = 3395 mSec "##--B--210--##" "15" "" 3395 Above 1000
209 19:47:48.67-19:47:45.28 = 7126867-7126528 mSec = 3395 mSec "##--F--218--##" "15" "" 3395 Above 1000
217 19:47:53.18-19:47:49.78 = 7127318-7126978 mSec = 3405 mSec "##--C--226--##" "16" "" 3405 Above 1000
225 19:47:57.68-19:47:54.29 = 7127768-7127429 mSec = 3395 mSec "##--G--234--##" "16" "" 3395 Above 1000
233 19:48:02.24-19:47:58.91 = 7128224-7127891 mSec = 3335 mSec "##--D--242--##" "16" "" 3335 Above 1000
241 19:48:06.79-19:48:03.55 = 7128679-7128355 mSec = 3245 mSec "##--A--250--##" "16" "" 3245 Above 1000
249 19:48:11.35-19:48:08.20 = 7129135-7128820 mSec = 3155 mSec "##--E--258--##" "16" "" 3155 Above 1000
E:\Test\Fill>
http://imgur.com/C662L50
Regards
Alan