summaryrefslogtreecommitdiff
path: root/archiver
blob: 8f78f2b7d24dc55afc3a69523f659723271c2793 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/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

    if [[ -f "$RESULTS_PATH/data.csv" ]]; then 
        rm "$RESULTS_PATH/data.csv"
    fi

    aggregate_files > "$RESULTS_PATH/data.csv"
}

aggregate_files() {
    ALL_ROWS=$(awk FNR-1 "$RESULTS_PATH"/*.csv 2>/dev/null | sort -t$'\t' -k6,6 -n) 
    STRATS=$(echo "$ALL_ROWS" | awk -F '\t' '{print $5}' | sort | uniq)

    OUTPUT=""
    while read -r STRAT; do
        [ -z "$STRAT" ] && continue
        ROWS=$(echo "$ALL_ROWS" | grep -P "\t$STRAT\t")
        OUTPUT+="$ROWS\n"
    done <<< "$STRATS"

    echo -e "$(header)\n$OUTPUT" | head -n-1
}

header() {
    echo -e "model\tquery\tsolved\tresult\tstrategy\ttime\tdate\ttime-limit\tmemory\texit-code\tformula\ttimed-out\terror-msg\tdiscoveredStates\texploredStates\texpandedStates\tmaxTokens\tsearchTime"
}

help() {
cat << EOF
usage: $0 RESULTS-DIR

Aggregate data from search stragey benchmark

EOF
}

main "$@"