let bench = [ ['tag', 'image']; # ['simple-dockerfile', 'react-simple', # ['multi-stage-dockerfile', 'react-multistage'], # ['node-alpine-dockerfile', 'react-multistage-alpine'], # ['nginx-dockerfile', 'react-nginx'], # ['nginx-alpine-dockerfile', 'react-nginx-alpine'], # ['bun-rspack-dockerfile', 'react-bun-rspack'], ['nginx-distroless-dockerfile', 'react-nginx-distroless'] ] for entry in $bench { echo $'Switching to branch ($entry.tag)' echo '' git checkout $entry.tag docker build -t $entry.image . } mut benchmark: table = [] git checkout main for entry: record in $bench { mut sum = 0ns mut max = 0ns mut min = 0ns let filename = './build_results' + $entry.tag + '.csv' let bench_res = open $filename let $benchmark_size = $bench_res | length for res in $bench_res { let time = $res | get time | into duration $sum += $time if $max == 0ns or $time >= $max { $max = $time } if $min == 0ns or $time <= $min { $min = $time } } let image_size = docker image ls $entry.image | from ssv | get 0 | get SIZE | into filesize let row table = [ ['tag', 'image', 'image_size', 'median_time', 'max_time', 'min_time', 'total_time', 'max_size', 'benchmark_size']; [$'($entry.tag)', $'($entry.image)', $image_size, ($sum / $benchmark_size), $max, $min, $sum, ($image_size * $benchmark_size), $benchmark_size] ] $benchmark = ($benchmark ++ $row) } $benchmark | to md --pretty | save -f benchmark.md # git add . # git commit -m $"updated README for benchmarks (date now | format date '%+') [CI SKIP]" # git push