home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 1995 November
/
PCWK1195.iso
/
inne
/
podstawy
/
dos
/
4dos
/
4uzytki
/
jambtm02.exe
/
EVALUATE.BTM
< prev
next >
Wrap
Text File
|
1992-11-15
|
2KB
|
51 lines
*REM This batch file is Freeware, free to use and redistribute unmodified *
*REM Jouni Miettunen * jon@stekt.oulu.fi * Oulu * Finland * Europe * 1992 *
*REM Evaluate an average running time for an alias/command/program.
*REM Note: trouble with redirection again. evaluate wc<file.txt 5 doesn't work.
*REM Timestamp 15-Nov-1992
*REM Can't do "unalias *" in case u want to execute an alias, so I've tried
*REM to drop *'s all over the place, hope there's enough B*)
*break on^*setlocal^*if %# != 2 .or. "%@int[%2]" != "%2" *goto info
*REM Find out what is the command. Are there quotes? Prepare log file.
*set c=%1^*if %@ascii[%c]==34 *set c=%@substr[%c,1,%@eval[%@len[%c]-2]]
*set index=%2^*echo ----- Run at %_date %_time>>%@name[%@word[0,%c]].log
*set base=%@lines[%@name[%@word[0,%c]].log]
*REM Execute "command" for a "number" times and record elapsed time into log
:period
*timer>nul^%@exec[%c]>&nul^*timer>>%@name[%@word[0,%c]].log^*set index=%@eval[%index-1]
*if %index gt 0 *goto period
*REM Calculate average running time
*echos Calculating average running time, please wait...
:loop
*set index=%@eval[%index+1]^*set a=%@line[%@name[%@word[0,%c]].log,%@eval[%base+%index]]
*set total=%@eval[%total+%@substr[%@word[-0,%a],4,-5]+%@substr[%@word[-0,%a],7,-2]*60]
*if %index lt %2 *goto loop
*set total=%@eval[%total/%2]
*screen %_row 0
*echo ----- Average running time of [ %@upper[%c] ] was %total seconds|*tee/a %@name[%@word[0,%c]].log
*goto end
:info
*echo Usage: %@lower[%@name[%0]] command number
*text
Runs command number times, creates a log file and calculates average running
time. I've presumed no command runs over an hour. You may want to fix that..
If command needs arguments, place the command in quatation marks.
*endtext
*echo Example: %@lower[%@name[%0]] "df -a" 10
:end
*break off^*quit