Skip to content

Commit

Permalink
#85 show metrics total
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Oct 2, 2023
1 parent fe63e5e commit 9a80ead
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
31 changes: 18 additions & 13 deletions steps/measure-file.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,22 @@ start=$(date +%s%N)

mkdir -p "$(dirname "${javam}")"
metrics=$(find "${LOCAL}/metrics/" -type f -exec basename {} \;)
echo "${metrics}" | while IFS= read -r m; do
if timeout 30m "metrics/${m}" "${java}" "${javam}"; then
while IFS= read -r t; do
IFS=' ' read -r -ra M <<< "${t}"
echo "${M[1]}" > "${javam}.${M[0]}"
done < "${javam}"
else
echo "Failed to collect ${m} for ${java}"
fi
done

echo "$(echo "${metrics}" | wc -w | xargs) scripts \
collected $(find "${javam}".* -type f | wc -l | xargs) metrics \
echo "${metrics}" | {
declare -i sum=0
while IFS= read -r m; do
if timeout 30m "metrics/${m}" "${java}" "${javam}"; then
while IFS= read -r t; do
IFS=' ' read -r -ra M <<< "${t}"
echo "${M[1]}" > "${javam}.${M[0]}"
if [ ! "${M[1]}" = "NaN" ]; then
sum=$((sum + M[1]))
fi
done < "${javam}"
else
echo "Failed to collect ${m} for ${java}"
fi
done
echo "$(echo "${metrics}" | wc -w | xargs) scripts \
collected $(find "${javam}".* -type f | wc -l | xargs) metrics (sum=${sum}) \
for $(basename "${java}") (${pos}/${total})$("${LOCAL}/help/tdiff.sh" "${start}")"
}
3 changes: 2 additions & 1 deletion tests/steps/test-measure-file.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ temp=$1

java="${temp}/Foo(xls;)';a привет '\".java"
echo "class Foo {}" > "${java}"
"${LOCAL}/steps/measure-file.sh" "${java}" "${temp}/m">/dev/null
msg=$("${LOCAL}/steps/measure-file.sh" "${java}" "${temp}/m")
echo "${msg}" | (grep "sum=0" && exit 1 || true)
test -e "${temp}/m"
echo "👍🏻 Single file measured correctly"
2 changes: 1 addition & 1 deletion tests/steps/test-measure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ java="${TARGET}/github/${repo}/${name}"
mkdir -p "$(dirname "${java}")"
echo "class Foo {}" > "${java}"
msg=$("${LOCAL}/steps/measure.sh")
echo "${msg}" | grep "metrics for Foo.java (1/1)" >/dev/null
echo "${msg}" | grep "for Foo.java (1/1)" >/dev/null
echo "${msg}" | grep "All metrics calculated in 1 files" >/dev/null
test -e "${TARGET}/measurements/${repo}/${name}.m"
echo "👍🏻 Measured metrics correctly"

0 comments on commit 9a80ead

Please sign in to comment.