#!/usr/bin/env ion

# set path to include sn
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 = $HOME/programming

# 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 = ["sn fat $path" "du -hacd2 -t1M $path" "sn fat $path --exclude target/debug" "du -hacd2 -t1M $path --exclude target/debug" "sn sort $path" "du -acd2 --bytes $path | sort -n | head -n8" "sn ar $path" "sn all $path"] # "du -hac $path | rg $regex" "du -hac $path | grep -P $regex" "sn ar -g $path" "sn ar $path"]

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

#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
