I'm very new with .bat files! But a quick learner.
I'm an engineering student and am working with a wave simulation model. I need to time the computation time, and am trying to do this by setting a variable StartTime=%time% just before I run the simulation, and after the simulation has ended I set EndTime=%time%, and with this I want to calculate the computation time. I run the model by opening a .bat file swashcmd.bat and changing the directory to the folder with my input file file_name.sws and then using the command swashrun file_name.sws.
I've tried to make a .bat file that I run from swashcmd.bat
@echo off
cd %USERPROFILE%\Dropbox\Bachelor\SWASH\testcases\Compiled\a11stwav
set StartTime=%time%
swashrun a11stw01
echo Computation done
set EndTime=%time%
This changes the directory and runs the simulation, but I can't verify that anything afterwards is carried out.
I've tried to make a .bat file that opens swashcmd.bat, and runs the simulation
@echo off
cd C:\Program Files\swash\
swashcmd.bat
cd C:\Users\dk46739\Dropbox\Bachelor\SWASH\testcases\Compiled\a11stwav
This starts the swashcmd.bat but does not change the directory.
It is beyond me to change anything in swashcmd.bat. Is it possible to do what I want without changing the swashcmd.bat file? And which way around (running a .bat from swashcmd.bat or running swashcmd.bat from a .bat) is better? (and why)
^
Opdate 1
With call
cd C:\Program Files\swash\
call swashcmd.bat
cd C:\Users\dk46739\Dropbox\Bachelor\SWASH\testcases\Compiled\a11stwav
Stops after calling swashcmd.bat
Opdate 2
Tried calling my .bat file from swashcmd.bat with cal. EndTime is not stored. Expanding the bat file to output star and end time to a .txt file when saving start and end time works.
getTimestamp.batis a helper batch file to manipulate and measure all sorts of time and date variables and can be found here - dostips.com/forum/viewtopic.php?p=27422#p27422 and it can calculate the elapsed time in varied manners. If your wave simulation is in the order of 5 to 10 seconds then the latency in running batch files could be an issue.swashrunis a batch file too, you need to execute it with acallcommand so that the execution returns toswashcmdandset EndTime=...is executed eventually. Also, you are storing both times but are never displaying them (or so it seems).