#!/bin/bash
function run() {
    OLD=0
    NEW=0
    NEWP=0
    EXECS=$1
    SIZE=$2
    RUNS=$3
    for ((i = 0; i < $EXECS; i++)) do
        SEL=$(A=$(shuf -i 0-10 -n 1); echo $(($A % 2)))
        if [ $SEL -eq 0 ]; then
            T_OLD=$(./gto $SIZE $RUNS)
            T_NEW=$(./gt $SIZE $RUNS)
            T_NEWP=$(./gtp $SIZE $RUNS)
        else
            T_NEW=$(./gt $SIZE $RUNS)
            T_NEWP=$(./gtp $SIZE $RUNS)
            T_OLD=$(./gto $SIZE $RUNS)
        fi
        NEW=$NEW+$T_NEW
        OLD=$OLD+$T_OLD
        NEWP=$NEWP+$T_NEWP
    done
    SPEED=$(echo "($OLD) / ($NEW)" | bc -l)
    SPEEDP=$(echo "($OLD) / ($NEWP)" | bc -l)
    echo "$SIZE -> $SPEED $SPEEDP"
}

run $1 16 500
run $1 32 500
run $1 64 100
run $1 128 50
run $1 256 10
run $1 1024 10
