Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-06-04 08:56:25

0001 #!/usr/bin/env bash
0002 ## Run full_command under /usr/bin/time, capturing exit code and resource metrics.
0003 ## Source this after setting full_command, e.g.:
0004 ##   full_command="root.exe -q -b '...'"
0005 ##   . ${SPHENIXPROD_SCRIPT_PATH}/common_runscript_exec.sh
0006 ##
0007 ## Sets: status_f4a, user_cpu, sys_cpu, max_rss_kb
0008 ## Follow up with stageout calls as needed, then source common_runscript_finish.sh.
0009 
0010 echo "--- Executing macro"
0011 echo "${full_command}"
0012 time_file=$(mktemp)
0013 /usr/bin/time -v -o "${time_file}" bash -c "${full_command}"
0014 status_f4a=$?
0015 user_cpu=$(  awk '/User time \(seconds\)/     {print $NF}' "${time_file}")
0016 sys_cpu=$(   awk '/System time \(seconds\)/   {print $NF}' "${time_file}")
0017 max_rss_kb=$(awk '/Maximum resident set size/ {print $NF}' "${time_file}")
0018 rm -f "${time_file}"
0019 
0020 if [[ ${status_f4a} -ne 0 ]]; then
0021     echo "ERROR: Macro exited with code ${status_f4a}. Aborting."
0022     . ${SPHENIXPROD_SCRIPT_PATH}/common_runscript_finish.sh
0023 fi