Skip to content

Commit

Permalink
added timer to measurement steps; send duration time; fixed formattin… (
Browse files Browse the repository at this point in the history
#22)

* added timer to measurement steps; send duration time; fixed formatting error with one of the cpus

* another cpu formatting fix
  • Loading branch information
dan-mm authored Jun 2, 2023
1 parent e06e341 commit e4f2678
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
23 changes: 17 additions & 6 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@ runs:
run: |
killall -9 -q /tmp/eco-ci/demo-reporter || true
/tmp/eco-ci/demo-reporter | tee -a /tmp/eco-ci/cpu-util-total.txt > /tmp/eco-ci/cpu-util.txt &
# start a timer
date +%s > /tmp/eco-ci/timer.txt
date +%s > /tmp/eco-ci/timer-total.txt
- if: inputs.task == 'get-measurement'
id: run-lap-model
Expand All @@ -160,7 +164,7 @@ runs:
# first activate our venv
source /tmp/eco-ci/venv/bin/activate
## make a note that we cannot use --eneryg, skew the result as we do not have an input delay.
## make a note that we cannot use --energy, skew the result as we do not have an input delay.
# this works because demo-reporter is 1/second
if [[ "$ECO_CI_MODEL_NAME" == "unknown" ]]; then
cat /tmp/eco-ci/cpu-util.txt | python3.10 /tmp/eco-ci/spec-power-model/xgb.py --silent | tee -a /tmp/eco-ci/energy-total.txt > /tmp/eco-ci/energy.txt
Expand Down Expand Up @@ -191,13 +195,16 @@ runs:
label="Measurement #$GET_MEASUREMENT_COUNT"
fi
# this is the time in seconds that the measurement took
measurement_time=$(($(date +%s) - $(cat /tmp/eco-ci/timer.txt)))
cpu_avg=$(awk '{ total += $1; count++ } END { print total/count }' /tmp/eco-ci/cpu-util.txt)
total_energy=$(awk '{sum+=$1} END {print sum}' /tmp/eco-ci/energy.txt)
power_avg=$(awk '{ total += $1; count++ } END { print total/count }' /tmp/eco-ci/energy.txt)
# Append the information gathered here to an ENV variable string that will form the table to be
# shown during display-results
display_line="$ECO_CI_MEASUREMENT_TABLE_LINES|${label}|${cpu_avg}|${total_energy}|${power_avg}|"
display_line="$ECO_CI_MEASUREMENT_TABLE_LINES|${label}|${cpu_avg}|${total_energy}|${power_avg}|${measurement_time}|"
echo "ECO_CI_MEASUREMENT_TABLE_LINES=${display_line}\n" >> $GITHUB_ENV
echo ${total_energy} >> /tmp/eco-ci/energy-values.txt
Expand All @@ -212,7 +219,7 @@ runs:
unit="mJ"
eco_ci_model_name=$(echo $ECO_CI_MODEL_NAME | jq -Rr @uri)
curl -X POST "$add_endpoint" -H 'Content-Type: application/json' -d "{\"value\":\"$value_mJ\",\"unit\":\"$unit\",\"cpu\":\"$eco_ci_model_name\",\"commit_hash\":\"${{ github.sha }}\",\"repo\":\"${{ github.repository }}\",\"branch\":\"${{ inputs.branch }}\",\"workflow\":\"$ECO_CI_WORKFLOW_ID\",\"run_id\":\"${{ github.run_id }}\",\"project_id\":\"\",\"label\":\"$label\", \"source\":\"github\"}"
curl -X POST "$add_endpoint" -H 'Content-Type: application/json' -d "{\"value\":\"$value_mJ\",\"unit\":\"$unit\",\"cpu\":\"$eco_ci_model_name\",\"commit_hash\":\"${{ github.sha }}\",\"repo\":\"${{ github.repository }}\",\"branch\":\"${{ inputs.branch }}\",\"workflow\":\"$ECO_CI_WORKFLOW_ID\",\"run_id\":\"${{ github.run_id }}\",\"project_id\":\"\",\"label\":\"$label\", \"source\":\"github\",\"duration\":\"$measurement_time\"}"
fi
# write data to output
Expand All @@ -226,6 +233,7 @@ runs:
killall -9 -q /tmp/eco-ci/demo-reporter || true
/tmp/eco-ci/demo-reporter | tee -a /tmp/eco-ci/cpu-util-total.txt > /tmp/eco-ci/cpu-util.txt &
date +%s > /tmp/eco-ci/timer.txt
else
echo "Skipping measurement as no data was collected since last call"
fi
Expand All @@ -250,14 +258,17 @@ runs:
fi
if [[ ${{ inputs.display-table }} == 'true' ]]; then
echo "|Label|🖥 avg. CPU utilization [%]|🔋 Total Energy [Joules]|🔌 avg. Power [Watts]|" >> $GITHUB_STEP_SUMMARY
echo "|---|---|---|---|" >> $GITHUB_STEP_SUMMARY
echo "|Label|🖥 avg. CPU utilization [%]|🔋 Total Energy [Joules]|🔌 avg. Power [Watts]|Duration [Seconds]|" >> $GITHUB_STEP_SUMMARY
echo "|---|---|---|---|---|" >> $GITHUB_STEP_SUMMARY
cpu_avg=$(awk '{ total += $1; count++ } END { print total/count }' /tmp/eco-ci/cpu-util-total.txt)
total_energy=$(awk '{sum+=$1} END {print sum}' /tmp/eco-ci/energy-total.txt)
power_avg=$(awk '{ total += $1; count++ } END { print total/count }' /tmp/eco-ci/energy-total.txt)
final_line="$ECO_CI_MEASUREMENT_TABLE_LINES|Total Run|${cpu_avg}|${total_energy}|${power_avg}|"
# this is the time in seconds that the measurement took
measurement_time=$(($(date +%s) - $(cat /tmp/eco-ci/timer-total.txt)))
final_line="$ECO_CI_MEASUREMENT_TABLE_LINES|Total Run|${cpu_avg}|${total_energy}|${power_avg}|${measurement_time}|"
echo -e "$final_line" >> $GITHUB_STEP_SUMMARY
echo '' >> $GITHUB_STEP_SUMMARY
fi
Expand Down
4 changes: 2 additions & 2 deletions scripts/init_variables.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ elif [[ "$model_name" == *"8370C"* ]]; then

elif [[ "$model_name" == *"E5-2673 v4"* ]]; then
echo "Found E5-2673 v4 model"
echo "ECO_CI_MODEL_NAME='E5-2673'" >> $GITHUB_ENV
echo "ECO_CI_MODEL_NAME=E5-2673v4" >> $GITHUB_ENV

echo "ECO_CI_TDP=165" >> $GITHUB_ENV;
echo "ECO_CI_CPU_THREADS=52" >> $GITHUB_ENV;
Expand All @@ -46,7 +46,7 @@ elif [[ "$model_name" == *"E5-2673 v4"* ]]; then

elif [[ "$model_name" == *"E5-2673 v3"* ]]; then
echo "Found E5-2673 v3 model"
echo "ECO_CI_MODEL_NAME='E5-2673 v3'" >> $GITHUB_ENV
echo "ECO_CI_MODEL_NAME=E5-2673v3" >> $GITHUB_ENV

echo "ECO_CI_TDP=110" >> $GITHUB_ENV;
echo "ECO_CI_CPU_THREADS=24" >> $GITHUB_ENV;
Expand Down

0 comments on commit e4f2678

Please sign in to comment.