Skip to content
Snippets Groups Projects
Commit bb35bb98 authored by Mario's avatar Mario
Browse files

Added some time measurements

parent 8f3b3358
No related branches found
No related tags found
No related merge requests found
Pipeline #1845021 passed
# About this branch
This branch is used for timing purposes. It will be periodically updated by merging `devel`, but no new features will be implemented here. The Scan Operator in this branch will produce a `.json` file containing detailed timing inforamation regarding all the functions that this framework is using. If we find this useful enough, we can always merge into `devel` in a later stage.
The Scan Operator is an integration tool for scan data and DCS data. These are its main features: The Scan Operator is an integration tool for scan data and DCS data. These are its main features:
- Calls Yarr repeatedly to **run a sequence of scans on Rd53a**. - Calls Yarr repeatedly to **run a sequence of scans on Rd53a**.
......
#!/bin/bash #!/bin/bash
export SOBASE=$(cd $(dirname $0); pwd)
export TIMING_OUT="$SOBASE/timing.json"
jq -n '{"total"}' > tmp && mv tmp $TIMING_OUT
jq '.total += {"type": "total"}' $TIMING_OUT > tmp && mv tmp $TIMING_OUT
START_ALL=$(date +%s.%N)
dcsOnOff=false dcsOnOff=false
ivCurve=0 ivCurve=0
quietMode=0 quietMode=0
...@@ -50,7 +56,10 @@ export YARR_DIR=`jq -j '.YARR.YARR_directory' $CFGFILE` ...@@ -50,7 +56,10 @@ export YARR_DIR=`jq -j '.YARR.YARR_directory' $CFGFILE`
export CFGFILE=$CFGFILE export CFGFILE=$CFGFILE
export SCAN_DIR=$YARR_DIR/configs/scans/rd53a/ export SCAN_DIR=$YARR_DIR/configs/scans/rd53a/
export RunCounter_path=$HOME/.yarr/runCounter export RunCounter_path=$HOME/.yarr/runCounter
export SOBASE=$(cd $(dirname $0); pwd)
jq '. += {"modules"}' $TIMING_OUT > tmp && mv tmp $TIMING_OUT
jq '.modules += []' $TIMING_OUT > tmp && mv tmp $TIMING_OUT
if [ $dcsOnOff ] || [ $dcsMnitor ] || [$ivCurve] if [ $dcsOnOff ] || [ $dcsMnitor ] || [$ivCurve]
then then
...@@ -59,7 +68,12 @@ then ...@@ -59,7 +68,12 @@ then
fi fi
if [ $ivCurve != 0 ] if [ $ivCurve != 0 ]
then then
jq '.modules += [{"label": "iv/vi curves"}]' $TIMING_OUT > tmp && mv tmp $TIMING_OUT
jq '.modules[-1] += {"type": "iv_script"}' $TIMING_OUT > tmp && mv tmp $TIMING_OUT
START=$(date +%s.%N)
python3 $SOBASE/libDCS/qaqc.py -e $(jq -j '.dcs_control.LR_config' $CFGFILE) -j $SOBASE/configs/ivscan.json -w $ivCurve python3 $SOBASE/libDCS/qaqc.py -e $(jq -j '.dcs_control.LR_config' $CFGFILE) -j $SOBASE/configs/ivscan.json -w $ivCurve
END=$(date +%s.%N)
jq --argjson a $(echo "($END - $START)*1000" | bc) '.modules[-1] += {"time_real": "\($a)"}' $TIMING_OUT > tmp && mv tmp $TIMING_OUT
fi fi
if [ -z $module_id ];then if [ -z $module_id ];then
echo "You didn't specify the Module ID (option '-m')." echo "You didn't specify the Module ID (option '-m')."
...@@ -76,6 +90,9 @@ if $createConfig ; then ...@@ -76,6 +90,9 @@ if $createConfig ; then
fi fi
if $dcsOnOff ;then if $dcsOnOff ;then
jq '.modules += [{"label": "turn on DCS"}]' $TIMING_OUT > tmp && mv tmp $TIMING_OUT
jq '.modules[-1] += {"type": "scan_operator"}' $TIMING_OUT > tmp && mv tmp $TIMING_OUT
START=$(date +%s.%N)
echo -e "\nTurning ON the DCS..." echo -e "\nTurning ON the DCS..."
bin="$(jq -j '.dcs_control.LR_binary' $CFGFILE)" bin="$(jq -j '.dcs_control.LR_binary' $CFGFILE)"
cfg="$(jq -j '.dcs_control.LR_config' $CFGFILE)" cfg="$(jq -j '.dcs_control.LR_config' $CFGFILE)"
...@@ -88,6 +105,8 @@ if $dcsOnOff ;then ...@@ -88,6 +105,8 @@ if $dcsOnOff ;then
I="$(jq -j ".dcs_control.channels[$i].current" $CFGFILE)" I="$(jq -j ".dcs_control.channels[$i].current" $CFGFILE)"
python3 $SOBASE/libDCS/qaqc.py -e $cfg -c $chn power-on python3 $SOBASE/libDCS/qaqc.py -e $cfg -c $chn power-on
done done
END=$(date +%s.%N)
jq --argjson a $(echo "($END - $START)*1000" | bc) '.modules[-1] += {"time_real": "\($a)"}' $TIMING_OUT > tmp && mv tmp $TIMING_OUT
fi fi
echo -e "\nRunning the sequence of scans" echo -e "\nRunning the sequence of scans"
...@@ -118,6 +137,9 @@ done ...@@ -118,6 +137,9 @@ done
if $dcsOnOff ;then if $dcsOnOff ;then
jq '.modules += [{"label": "turn off DCS"}]' $TIMING_OUT > tmp && mv tmp $TIMING_OUT
jq '.modules[-1] += {"type": "scan_operator"}' $TIMING_OUT > tmp && mv tmp $TIMING_OUT
START=$(date +%s.%N)
echo -e "\nTurning OFF the DCS..." echo -e "\nTurning OFF the DCS..."
bin="$(jq -j '.dcs_control.LR_binary' $CFGFILE)" bin="$(jq -j '.dcs_control.LR_binary' $CFGFILE)"
cfg="$(jq -j '.dcs_control.LR_config' $CFGFILE)" cfg="$(jq -j '.dcs_control.LR_config' $CFGFILE)"
...@@ -128,4 +150,9 @@ if $dcsOnOff ;then ...@@ -128,4 +150,9 @@ if $dcsOnOff ;then
chn="$(jq -j ".dcs_control.channels[$i].name" $CFGFILE)" chn="$(jq -j ".dcs_control.channels[$i].name" $CFGFILE)"
python3 $SOBASE/libDCS/qaqc.py -e $cfg -c $chn power-off python3 $SOBASE/libDCS/qaqc.py -e $cfg -c $chn power-off
done done
END=$(date +%s.%N)
jq --argjson a $(echo "($END - $START)*1000" | bc) '.modules[-1] += {"time_real": "\($a)"}' $TIMING_OUT > tmp && mv tmp $TIMING_OUT
fi fi
END_ALL=$(date +%s.%N)
jq --argjson a $(echo "($END_ALL - $START_ALL)*1000" | bc) '.total += {"time_real": "\($a)"}' $TIMING_OUT > tmp && mv tmp $TIMING_OUT
...@@ -64,6 +64,7 @@ do ...@@ -64,6 +64,7 @@ do
done done
check_value $module_id check_value $module_id
check_value $scan check_value $scan
ScanName=${scan##*/}
if [ ! -e $scan ] ;then if [ ! -e $scan ] ;then
scan="$SCAN_DIR$scan.json" scan="$SCAN_DIR$scan.json"
...@@ -86,6 +87,11 @@ LOGFILE="${result_data_DIR}OperatorLog."`date "+%Y%m%d_%H%M%S"` ...@@ -86,6 +87,11 @@ LOGFILE="${result_data_DIR}OperatorLog."`date "+%Y%m%d_%H%M%S"`
############################################### ###############################################
if ${dcsMonitor} ;then if ${dcsMonitor} ;then
jq '.modules += [{"label": "Read Single DCS"}]' $TIMING_OUT > tmp && mv tmp $TIMING_OUT
jq --argjson a $ScanName '.modules[-1] += {"type": "\($a)"}' $TIMING_OUT > tmp && mv tmp $TIMING_OUT
START=$(date +%s.%N)
echo " | | [INFO] Getting single [V, I] measurement" echo " | | [INFO] Getting single [V, I] measurement"
cfg="$(jq -j '.dcs_control.LR_config' $CFGFILE)" cfg="$(jq -j '.dcs_control.LR_config' $CFGFILE)"
chn="" chn=""
...@@ -98,11 +104,19 @@ if ${dcsMonitor} ;then ...@@ -98,11 +104,19 @@ if ${dcsMonitor} ;then
done done
chn="${chn::-1}" chn="${chn::-1}"
END=$(date +%s.%N)
jq --argjson a $(echo "($END - $START)*1000" | bc) '.modules[-1] += {"time_real": "\($a)"}' $TIMING_OUT > tmp && mv tmp $TIMING_OUT
python3 $SOBASE/libDCS/qaqc.py -e $cfg -c $chn measure python3 $SOBASE/libDCS/qaqc.py -e $cfg -c $chn measure
# Tell read_dcs_background.sh that we're performing a scan # Tell read_dcs_background.sh that we're performing a scan
echo "1" > $SOBASE/.tmp echo "1" > $SOBASE/.tmp
$SOBASE/libDCS/read_dcs_background.sh & $SOBASE/libDCS/read_dcs_background.sh &
fi fi
jq '.modules += [{"label": "chip config"}]' $TIMING_OUT > tmp && mv tmp $TIMING_OUT
jq --argjson a $ScanName '.modules[-1] += {"type": "\($a)"}' $TIMING_OUT > tmp && mv tmp $TIMING_OUT
START=$(date +%s.%N)
targetCharge=$(jq -j '.YARR.scan.target_charge' $CFGFILE) targetCharge=$(jq -j '.YARR.scan.target_charge' $CFGFILE)
targetPreamp=$(jq -j '.YARR.scan.target_preamp' $CFGFILE) targetPreamp=$(jq -j '.YARR.scan.target_preamp' $CFGFILE)
targetTot=$(jq -j '.YARR.scan.target_tot' $CFGFILE) targetTot=$(jq -j '.YARR.scan.target_tot' $CFGFILE)
...@@ -137,6 +151,13 @@ do ...@@ -137,6 +151,13 @@ do
jq --argjson a $specNum '.ctrlCfg.cfg.specNum = $a' $ctrlFile > tmp && mv tmp $ctrlFile jq --argjson a $specNum '.ctrlCfg.cfg.specNum = $a' $ctrlFile > tmp && mv tmp $ctrlFile
done done
END=$(date +%s.%N)
jq --argjson a $(echo "($END - $START)*1000" | bc) '.modules[-1] += {"time_real": "\($a)"}' $TIMING_OUT > tmp && mv tmp $TIMING_OUT
jq '.modules += [{"label": "scan"}]' $TIMING_OUT > tmp && mv tmp $TIMING_OUT
jq --argjson a $ScanName '.modules[-1] += {"type": "\($a)"}' $TIMING_OUT > tmp && mv tmp $TIMING_OUT
START=$(date +%s.%N)
comm="$YARR_DIR/bin/scanConsole -r $ctrlFile -c $cnctFile -p -t ${targetAmpOrCharge} ${targetTot} -s ${scan} -m 1 $localdbOpt" #> /dev/null 2>1 comm="$YARR_DIR/bin/scanConsole -r $ctrlFile -c $cnctFile -p -t ${targetAmpOrCharge} ${targetTot} -s ${scan} -m 1 $localdbOpt" #> /dev/null 2>1
echo " | | [INFO] Calling Yarr's scanConsole" echo " | | [INFO] Calling Yarr's scanConsole"
echo "$comm" echo "$comm"
...@@ -154,6 +175,10 @@ else ...@@ -154,6 +175,10 @@ else
cd $YARR_DIR && $comm cd $YARR_DIR && $comm
fi fi
END=$(date +%s.%N)
jq --argjson a $(echo "($END - $START)*1000" | bc) '.modules[-1] += {"time_real": "\($a)"}' $TIMING_OUT > tmp && mv tmp $TIMING_OUT
if [ ! -z ${result_data_DIR} ]; then if [ ! -z ${result_data_DIR} ]; then
scan_result_path=$(readlink -f $YARR_DIR/data/last_scan) scan_result_path=$(readlink -f $YARR_DIR/data/last_scan)
...@@ -175,6 +200,10 @@ fi ...@@ -175,6 +200,10 @@ fi
# cmd="$YARR_DIR/bin/dbAccessor -F $SOBASE/configs/influxdb_connectivity.json -n $module_id -s ${result_data_DIR}/YARR_result/scanLog.json" # cmd="$YARR_DIR/bin/dbAccessor -F $SOBASE/configs/influxdb_connectivity.json -n $module_id -s ${result_data_DIR}/YARR_result/scanLog.json"
# echo " | | [INFO] $cmd" # echo " | | [INFO] $cmd"
jq '.modules += [{"label": "db sync"}]' $TIMING_OUT > tmp && mv tmp $TIMING_OUT
jq --argjson a $ScanName '.modules[-1] += {"type": "\($a)"}' $TIMING_OUT > tmp && mv tmp $TIMING_OUT
START=$(date +%s.%N)
END=$(date +%s.%N) END=$(date +%s.%N)
echo -ne "done $scan $(echo "$END - $START" | bc)\t\n" >> $SOBASE/temp.txt echo -ne "done $scan $(echo "$END - $START" | bc)\t\n" >> $SOBASE/temp.txt
#echo -ne "$(echo "$END - $START" | bc)\t" >> ./temp.txt #echo -ne "$(echo "$END - $START" | bc)\t" >> ./temp.txt
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment