Reputation: 347406
I have the following layout for my test suite:
TestSuite1.cmd:
In my single .cmd file, I call my program about 10 times with different input.
The problem is that the program that I run 10 times takes several hours to run each time.
Is there a way for me to parallelize all of these 10 runnings of my program while still somehow checking the return result and providing a proper output file and while still using a single .cmd file and to a single output file?
Upvotes: 2
Views: 5428
Reputation: 882028
Assuming they won't interfere with each other by writing to the same files,etc:
test1.cmd
:: intercept sub-calls.
if "%1"=="test2" then goto :test2
:: start sub-calls.
start test1.cmd test2 1
start test1.cmd test2 2
start test1.cmd test2 3
:: wait for sub-calls to complete.
:loop1
if not exist test2_1.flg goto :loop1
:loop2
if not exist test2_2.flg goto :loop2
:loop3
if not exist test2_3.flg goto :loop3
:: output results sequentially
type test2_1.out >test1.out
del /s test2_1.out
del /s test2_1.flg
type test2_2.out >test1.out
del /s test2_2.out
del /s test2_2.flg
type test2_3.out >test1.out
del /s test2_3.out
del /s test2_3.flg
goto :eof
:test2
:: Generate one output file
echo %1 >test2_%1.out
ping -n 31 127.0.0.1 >nul: 2>nul:
:: generate flag file to indicate finished
echo x >test2_%1.flg
This will start three concurrent processes each which echoes it's sequence number then wait 30 seconds.
All with one cmd file and (eventually) one output file.
Upvotes: 4
Reputation: 27045
try the command start, it spawns a new command prompt and you can send along any commands you want it to run.
I'd use this to spawn batch files that run the tests and then appends to a output.txt using >> as such:
testthingie.cmd >> output.txt
Upvotes: 0
Reputation: 1153
You will need to start the script with different parameters on different machines because whatever makes the program take so long for a task (IO, CPU time) will be in even shorter supply when multiple instances of your program run at once.
Only exception: the run time is cause by the program putting itself to sleep.
Upvotes: 0
Reputation: 105
Windows:
you create a Batch File that essentially calls:
start TestSuite1.cmd [TestParams1]
start TestSuite1.cmd [TestParams2]
and so on, which is essentially forking new command lines,
which would work, if the application can handle concurrent users (even if its the same User), and your TestSuite1.cmd is able to handle parameters.
Upvotes: 1
Reputation: 10820
Running things in parallel in batch files can be done via 'start' executable/command.
Upvotes: 1