Skip to content

Commit

Permalink
Update bash script for formatting tables
Browse files Browse the repository at this point in the history
  • Loading branch information
matteocam committed Jul 10, 2023
1 parent 4e94785 commit 5408af8
Showing 1 changed file with 46 additions and 4 deletions.
50 changes: 46 additions & 4 deletions fmt_estimates.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,12 +1,54 @@
#!/bin/bash


function estimate_info() {
WHOLE_NAME="$1"
DIR_NAME=$(dirname "$1")
MEAN=$(jq '.mean.point_estimate' $WHOLE_NAME | awk '{printf "%.2f", $1/1000000;}')
echo "$DIR_NAME $MEAN"
}
MEAN=$(jq '.mean.point_estimate' "$WHOLE_NAME" | awk '{printf "%.2f", $1/1000000;}')

# Division for batch
if echo "$DIR_NAME" | grep -q "100"; then
MEAN=$(echo "scale=2; $MEAN / 100" | bc)
fi


if echo "$DIR_NAME" | grep -q "base"; then
FMTTED_DIR=$(echo -n "$DIR_NAME" | cut -d / -f 4-5)
if echo "$DIR_NAME" | grep -q -i "$2"; then
printf "%-80s %s\n" "${FMTTED_DIR}" "${MEAN}ms"
fi
fi
}

export -f estimate_info

find . -type f -name "estimates.json" -exec bash -c "estimate_info \"{}\"" \;
function estimate_info_acc() {
estimate_info "$1" "acc"
}
export -f estimate_info_acc

function estimate_info_selrand() {
estimate_info "$1" "selrand "
}
export -f estimate_info_selrand

function estimate_info_pour() {
estimate_info "$1" "pour"
}
export -f estimate_info_pour

# Main code
echo

echo "--- Table 1 (Accumulator)----"
find . -type f -name "estimates.json" -exec bash -c "estimate_info_acc \"{}\"" \;
echo

echo "--- Table 2 (SelectAndRerand)----"
find . -type f -name "estimates.json" -exec bash -c "estimate_info_selrand \"{}\"" \;
echo

echo "--- Table 3 (Pour)----"
find . -type f -name "estimates.json" -exec bash -c "estimate_info_pour \"{}\"" \;
echo

0 comments on commit 5408af8

Please sign in to comment.