#!/usr/bin/env bash

echo "Building executable..."

cd "${FLAKE:-$(dirname $0)}"
if command -v nix; then
    cpu_schedulers="$(nix build --no-link --print-out-paths .#cpu-schedulers)/bin/cpu-schedulers"
else
    make
    cpu_schedulers="build/cpu-schedulers"
fi

num_processes=10

printf "compare\n$num_processes\n" >input.txt

proc_arrival=0
for i in $(seq 2 "$num_processes"); do
    echo -n "$proc_arrival," >>input.txt
    proc_arrival=$(($RANDOM % 100 + $proc_arrival))
done
echo "$proc_arrival" >>input.txt

for i in $(seq 2 "$num_processes"); do
    echo -n $((($RANDOM % 1250) ** 4 / 1000000000 + 1))"," >>input.txt
done
echo $((($RANDOM % 1250) ** 4 / 1000000000 + 1)) >>input.txt

for i in $(seq 2 "$num_processes"); do
    echo -n $(($RANDOM % 20))"," >>input.txt
done
echo $(($RANDOM % 20)) >>input.txt

"$cpu_schedulers" -m <input.txt
