summaryrefslogtreecommitdiffstats
path: root/src/etc/cpu-usage-over-time-plot.sh
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
commit698f8c2f01ea549d77d7dc3338a12e04c11057b9 (patch)
tree173a775858bd501c378080a10dca74132f05bc50 /src/etc/cpu-usage-over-time-plot.sh
parentInitial commit. (diff)
downloadrustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.tar.xz
rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.zip
Adding upstream version 1.64.0+dfsg1.upstream/1.64.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/etc/cpu-usage-over-time-plot.sh')
-rwxr-xr-xsrc/etc/cpu-usage-over-time-plot.sh59
1 files changed, 59 insertions, 0 deletions
diff --git a/src/etc/cpu-usage-over-time-plot.sh b/src/etc/cpu-usage-over-time-plot.sh
new file mode 100755
index 000000000..1c3425591
--- /dev/null
+++ b/src/etc/cpu-usage-over-time-plot.sh
@@ -0,0 +1,59 @@
+#!/bin/bash
+
+# A small script to help visualizing CPU usage over time data collected on CI
+# using `gnuplot`.
+#
+# This script is expected to be called with two arguments. The first is the full
+# commit SHA of the build you're interested in, and the second is the name of
+# the builder. For example:
+#
+# ./src/etc/cpu-usage-over-time-plot.sh 7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c x86_64-gnu
+#
+# That will generate `$builder.png` in the current directory which you can open
+# up to see a hopefully pretty graph.
+#
+# Improvements to this script are greatly appreciated!
+
+if [[ $# != 2 ]]; then
+ echo "expected 2 arguments, recieved $#"
+ echo "example usage: './src/etc/cpu-usage-over-time-plot.sh \
+7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c \
+x86_64-gnu'"
+ exit 1
+fi
+
+set -ex
+
+bucket=rust-lang-ci2
+commit=$1
+builder=$2
+
+curl -O https://$bucket.s3.amazonaws.com/rustc-builds/$commit/cpu-$builder.csv
+
+gnuplot <<-EOF
+reset
+set timefmt '%Y-%m-%dT%H:%M:%S'
+set xdata time
+set ylabel "CPU Usage %"
+set xlabel "Time"
+set datafile sep ','
+set term png size 3000,1000
+set output "$builder-$commit-cpu-usage-plot.png"
+set grid
+
+f(x) = mean_y
+fit f(x) 'cpu-$builder.csv' using 1:(100-\$2) via mean_y
+
+set label 1 gprintf("Average = %g%%", mean_y) center font ",18"
+set label 1 at graph 0.50, 0.25
+set xtics rotate by 45 offset -2,-2.4 300
+set ytics 10
+set boxwidth 0.5
+
+plot \\
+ mean_y with lines linetype 1 linecolor rgb "#ff0000" title "average", "cpu-$builder.csv" \\
+ using 1:(100-\$2) with points pointtype 7 pointsize 0.4 title "$builder", "" \\
+ using 1:(100-\$2) smooth bezier linewidth 3 title "bezier"
+EOF
+
+rm "cpu-$builder.csv"