#!/bin/bash

cd src;
make clean;
make all;
cd ..;

for instance_path in ./instances/* ; do
  echo $instance_path
  name=${instance_path##*/}
  LC_NUMERIC=en_US.utf8 perf stat -B -e cycles:u -e instructions:u -e branches:u -e branch-misses:u  -o ./results/perf_results/0_comp_2_$name.txt ./src/comp 2 $instance_path
  LC_NUMERIC=en_US.utf8 perf stat -B -e cycles:u -e instructions:u -e branches:u -e branch-misses:u  -o ./results/perf_results/0_comp_3_$name.txt ./src/comp 3 $instance_path
  for depth in {2,3,4,5}; do
    LC_NUMERIC=en_US.utf8 perf stat -B -e cycles:u -e instructions:u -e branches:u -e branch-misses:u  -o ./results/perf_results/1_alphabeta_"$depth"_"$name".txt ./src/alpha_beta $depth $instance_path
    LC_NUMERIC=en_US.utf8 perf stat -B -e cycles:u -e instructions:u -e branches:u -e branch-misses:u  -o ./results/perf_results/2_transpositiontable_"$depth"_"$name".txt ./src/transposition_table $depth $instance_path
    LC_NUMERIC=en_US.utf8 perf stat -B -e cycles:u -e instructions:u -e branches:u -e branch-misses:u  -o ./results/perf_results/3_optall_"$depth"_"$name".txt ./src/transposition_table_opt_all $depth $instance_path
    for i in {1,2,3}; do
      LC_NUMERIC=en_US.utf8 perf stat -B -e cycles:u -e instructions:u -e branches:u -e branch-misses:u  -o ./results/perf_results/3_opt"$i"_"$depth"_"$name".txt ./src/transposition_table_opt_"$i" $depth $instance_path
    done
  done
done
