This is how to get simulation durations for script and multiple runs

I ran in the problem a little while back that I needed to know how long my simulation actually took.
This because I made a script for sweeping a very specific set, thus I needed to know if it wouldn’t take to long.

Lumerical doesn’t provide a really good option for this, so I wrote a little script that works in lumerical for Linux servers.
I’m using redhat and for me it works perfectly, I have no slow down nor other issues.

You can use the script below however you see fit.

###Finding the actual time for simulation duration on a linux server (tested for redhat enterprise), no notable slow down
## Bob van de Voort
ii=1; #File counter if you need it and want to know the save individual times per run in different files
cmd1="touch"+filename+"\n ini_time=\"$(date +%s)\" \n echo $ini_time >>"+filename; #First command to created file if non-existent and append start time to file
system(cmd1); #executing the command, can be placed before or after switchtolayout, depending on what time you want to know

#switchtolayout to change parameters in script 

#Run you file

#After your file finishes running it will write down the time and calculate the difference between start and end times
cmd2="end_time=\"$(date +%s)\" \n echo $end_time >>"+filename; #appending the end time to file
system(cmd2); #executing command 2
cmd3="start=\"$(tail -2 "+filename+" | head -1)\" \n end=\"$(tail -1 "+filename+" | head -1)\" \n duration=\"$(date -d@$((end-start)) -u +%H:%M:%S)\" \n echo $duration >>"+filename; #Writing the duration in your textfile
system(cmd3); #executing command 3

Time_keeping_Lumerical_linux.fsp (1.2 KB)