#!/usr/bin/env ion

# set path to include sniff
let PATH=$HOME/.cargo/bin:$PATH

# make sure build is up to date
cargo build --release

# set path to binary
let binpath = target/release/sniff

#export CLICOLOR=0
let CLICOLOR=0

# set to a suitable path & decide whether to produce reports
let reports = "false"
for x in @args
    if test $x = "+reports"
        let reports = "true"
    end
end

#let path = .
let path = /home/vanessa/programming/haskell/forks/cabal

# set regex to compare to
let regex = '\'(.*?\\.(a|la|lo|o|ll|keter|bc|dyn_o|out|d|rlib|crate|min\\.js|hi|dyn_hi|jsexe|webapp|js\\.externs|toc|aux|fdb_latexmk|fls|egg-info|whl|js_a|js_hi|js_o|so.*|dump-.*|vba|crx|orig|elmo|elmi|pyc|mod|p_hi|p_o|prof|tix)\$|total)\' '

# initialize cache
echo 'initializing file system cache...'
sniff all $path > /dev/null

# set the benches
let benches = ["du -hac $path | rg $regex" "du -hac $path | grep -P $regex" "$binpath ar -g $path" "$binpath ar $path" "$binpath fast $path" "du -hacd2 $path"]

#do the actual benchmarks
if test $reports = "true"
    echo 'generating reports with benchmarks...'
    mkdir -p reports/
    bench --output reports/fast.html @benches
else
    bench @benches
end
