]> Untitled Git - lemmy.git/blob - scripts/compilation_benchmark.sh
Upgrade Rust version
[lemmy.git] / scripts / compilation_benchmark.sh
1 #!/bin/bash
2 set -e
3
4 times=3
5 duration=0
6 for ((i=0; i < times; i++)) ; do
7     echo "Starting iteration $i"
8     echo "cargo clean"
9     # to benchmark incremental compilation time, do a full build with the same compiler version first,
10     # and use the following clean command:
11     #cargo clean -p lemmy_utils
12     cargo clean
13     echo "cargo build"
14     start=$(date +%s.%N)
15     RUSTC_WRAPPER='' cargo build -q
16     end=$(date +%s.%N)
17     echo "Finished iteration $i after $(bc <<< "scale=0; $end - $start") seconds"
18     duration=$(bc <<< "$duration + $end - $start")
19 done
20
21 average=$(bc <<< "scale=0; $duration / $times")
22
23 echo "Average compilation time over $times runs is $average seconds"