]> git.lizzy.rs Git - rust.git/blob - src/etc/cpu-usage-over-time-plot.sh
Don't checkout llvm-project when the LLVM backend isn't built
[rust.git] / src / etc / cpu-usage-over-time-plot.sh
1 #!/bin/bash
2
3 # A small script to help visualizing CPU usage over time data collected on CI
4 # using `gnuplot`.
5 #
6 # This script is expected to be called with two arguments. The first is the full
7 # commit SHA of the build you're interested in, and the second is the name of
8 # the builder. For example:
9 #
10 #  ./src/etc/cpu-usage-over-time-plot.sh e699ea096fcc2fc9ce8e8bcf884e11496a31cc9f i686-mingw-1
11 #
12 # That will generate `$builder.png` in the current directory which you can open
13 # up to see a hopefully pretty graph.
14 #
15 # Improvements to this script are greatly appreciated!
16
17 set -ex
18
19 bucket=rust-lang-ci2
20 commit=$1
21 builder=$2
22
23 curl -O https://$bucket.s3.amazonaws.com/rustc-builds/$commit/cpu-$builder.csv
24
25 gnuplot <<-EOF
26 reset
27 set timefmt '%Y-%m-%dT%H:%M:%S'
28 set xdata time
29 set ylabel "CPU Usage %"
30 set xlabel "Time"
31 set datafile sep ','
32 set term png size 3000,1000
33 set output "$builder.png"
34 set grid
35
36 f(x) = mean_y
37 fit f(x) 'cpu-$builder.csv' using 1:(100-\$2) via mean_y
38
39 set label 1 gprintf("Average = %g%%", mean_y) center font ",18"
40 set label 1 at graph 0.50, 0.25
41 set xtics rotate by 45 offset -2,-2.4 300
42 set ytics 10
43 set boxwidth 0.5
44
45 plot \\
46    mean_y with lines linetype 1 linecolor rgb "#ff0000" title "average", \\
47    "cpu-$builder.csv" using 1:(100-\$2) with points pointtype 7 pointsize 0.4 title "$builder", \\
48    "" using 1:(100-\$2) smooth bezier linewidth 3 title "bezier"
49 EOF