summaryrefslogtreecommitdiff
path: root/archiver
diff options
context:
space:
mode:
authorAdam M. Stück <adam@adast.xyz>2022-11-23 11:37:28 +0100
committerAdam M. Stück <adam@adast.xyz>2022-12-16 22:17:18 +0100
commitc3dd7c95e17523e77e8558b9cb57176bc8275bea (patch)
tree8e496dc82dbfe2e07c033f6728dad8a4a6d90d6e /archiver
Improved file structure
Diffstat (limited to 'archiver')
-rwxr-xr-xarchiver65
1 files changed, 65 insertions, 0 deletions
diff --git a/archiver b/archiver
new file mode 100755
index 0000000..1c0bc79
--- /dev/null
+++ b/archiver
@@ -0,0 +1,65 @@
+#!/bin/bash
+
+RESULTS_PATH=$1
+
+main() {
+ if [ $# -eq 0 ]; then
+ help; exit 1
+ fi
+
+ case "$1" in
+ -h|--help)
+ help; exit ;;
+ esac
+
+ if [[ ! -d "$RESULTS_PATH" ]]; then
+ echo "error: invalid results path"
+ exit 1
+ fi
+
+ aggregate_files
+}
+
+aggregate_files() {
+ OUTPUT=""
+ HEADER_INSERTED=false
+
+ while IFS= read -r -d '' ENTRY
+ do
+ if [ $HEADER_INSERTED == true ]; then
+ FILE=$(tail -n +2 "$ENTRY")
+ else
+ FILE=$(cat "$ENTRY")
+ fi
+
+ OUTPUT+="$FILE\n"
+ HEADER_INSERTED=true
+ done < <(find "$RESULTS_PATH" -maxdepth 1 -type f -print0)
+
+ HEADER=$(echo -e "$OUTPUT" | head -n 1)
+ ALL_ROWS=$(echo -e "$OUTPUT" | tail -n +2 | sort -t$'\t' -k6,6 -n)
+ STRATS=$(echo -e "$ALL_ROWS" | awk -F '\t' '{print $5}' | sort | uniq)
+
+ OUTPUT=""
+ while read -r STRAT; do
+ [ -z "$STRAT" ] && continue
+ ROWS=$(echo -e "$ALL_ROWS" | grep -P "\t$STRAT\t")
+ OUTPUT+="$ROWS\n"
+ done <<< "$STRATS"
+
+ OUTPUT=$(echo -e "$HEADER\n$OUTPUT" | head -n -1)
+ echo -e "$OUTPUT" > "$RESULTS_PATH/data.csv"
+}
+
+help() {
+cat << EOF
+usage: $0 RESULTS-DIR
+
+Aggregate data from search stragey benchmark
+
+Options:
+ -h, --help Show this message
+EOF
+}
+
+main "$@"