#!/usr/bin/env ion

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

let CLICOLOR=0

# set to a suitable path & decide whether to produce reports
let reports = "false"
let parallel = "true"
let benchpath = "reports/bench.html"
let path = $HOME/programming
for x in @args
    if test $x = "+reports"
        let reports = "true"
    end
    if test $x = "+seq"
        let parallel = "false"
        let benchpath = "reports/bench-seq.html"
    end
end


let excluded = 'target/debug$'

# set the benches
let benches = ["sn ar $path" "sn all $path" "du -hacd2 $path" "sn fat $path" "du -hacd2 -t30M $path" "sn fat $path --exclude $excluded" "du -hacd2 -t30M $path --exclude target/debug"]
if test $parallel = "true"
    let benches = ["sn p $path" "du -hcd2 $path" "sn p -t30M $path" "du -hcd2 -t30M $path" "sn p -t30M --exclude $excluded $path" "du -hcd2 -t30M $path --exclude target/debug"]
end

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

#do the actual benchmarks

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