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 17set -ex 18 19bucket=rust-lang-ci2 20commit=$1 21builder=$2 22 23curl -O https://$bucket.s3.amazonaws.com/rustc-builds/$commit/cpu-$builder.csv 24 25gnuplot <<-EOF 26reset 27set timefmt '%Y-%m-%dT%H:%M:%S' 28set xdata time 29set ylabel "CPU Usage %" 30set xlabel "Time" 31set datafile sep ',' 32set term png size 3000,1000 33set output "$builder.png" 34set grid 35 36f(x) = mean_y 37fit f(x) 'cpu-$builder.csv' using 1:(100-\$2) via mean_y 38 39set label 1 gprintf("Average = %g%%", mean_y) center font ",18" 40set label 1 at graph 0.50, 0.25 41set xtics rotate by 45 offset -2,-2.4 300 42set ytics 10 43set boxwidth 0.5 44 45plot \\ 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" 49EOF 50