Skip to content

Instantly share code, notes, and snippets.

@nischalkumar
Last active March 25, 2023 06:25
Show Gist options
  • Save nischalkumar/aeb77fb659eb9c3d9248b239d35ca863 to your computer and use it in GitHub Desktop.
Save nischalkumar/aeb77fb659eb9c3d9248b239d35ca863 to your computer and use it in GitHub Desktop.
echo "" > data_final.csv
for i in {1..5}; do
./waf --run "pa2 --exp=exp$i" | grep -E 'Throughput|Average_Flow_Time' > output
#echo "$output" >> data_final.csv
first_throughput=""
last_throughput=""
last_flow_time=""
while read -r line; do
if [[ "$line" == *"Throughput:"* || "$line" == *"Average_Flow_Time:"* ]]; t$
words=($line)
for ((j=0; j<${#words[@]}; j++)); do
if [[ "${words[j]}" == "Throughput:" ]]; then
if [[ -z "$first_throughput" ]]; then
first_throughput="${words[j+1]}"
fi
last_throughput="${words[j+1]}"
elif [[ "${words[j]}" == "Average_Flow_Time:" ]]; then
last_flow_time="${words[j+1]}"
fi
done
echo "Output $i: First TP - $first_throughput, Last TP - $last_throughput$"
echo "$i,$first_throughput,$last_throughput,$last_flow_time" >> data_final.csv
fi
done <<< output
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment