#!/usr/bin/env ion

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

#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 = /home/vanessa/programming/haskell/forks/cabal
# let path = .

# 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)\' '

# set the benches
let benches = ["du -hacd2 $path" "sniff all $path" "sniff fast -a $path" "du -ha $path" "du -hacd2 -t1M $path" "sniff fat $path" "du -hacd2 -t1M $path --exclude target/debug" "sniff fat $path --exclude target/debug" "du --bytes -acd2 $path | sort -nr | head -n20" "sniff sort $path" "du --bytes -acd2 $path --exclude target/debug | sort -nr | head -n8" "sniff sort $path --exclude target/debug" "du -hac -t1M $path | rg $regex" "du -hac -t1M $path | grep -P $regex" "sniff ar -g -t1M $path" "du -hac $path | rg $regex" "du -hac $path | grep -P $regex" "sniff ar -g $path" "sniff ar $path" "sniff fast $path"]
#do the actual benchmarks

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