From 831ddf700d91b50ac8e3beffe35d7ee5f5dd5218 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 14 Jun 2019 08:31:43 -0700 Subject: [PATCH] ci: Add a script for generating CPU usage graphs This commit checks in a script which generates CPU usage graphs over time, expanding on the previous comment that was include in the collection file. --- src/ci/cpu-usage-over-time.py | 19 ++--------- src/etc/cpu-usage-over-time-plot.sh | 49 +++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 17 deletions(-) create mode 100755 src/etc/cpu-usage-over-time-plot.sh diff --git a/src/ci/cpu-usage-over-time.py b/src/ci/cpu-usage-over-time.py index 78427a6360a9f..daf21670b3339 100644 --- a/src/ci/cpu-usage-over-time.py +++ b/src/ci/cpu-usage-over-time.py @@ -30,23 +30,8 @@ # the second column is always zero. # # Once you've downloaded a file there's various ways to plot it and visualize -# it. For command line usage you can use a script like so: -# -# set timefmt '%Y-%m-%dT%H:%M:%S' -# set xdata time -# set ylabel "Idle CPU %" -# set xlabel "Time" -# set datafile sep ',' -# set term png -# set output "printme.png" -# set grid -# builder = "i686-apple" -# plot "cpu-".builder.".csv" using 1:2 with lines title builder -# -# Executed as `gnuplot < ./foo.plot` it will generate a graph called -# `printme.png` which you can then open up. If you know how to improve this -# script or the viewing process that would be much appreciated :) (or even if -# you know how to automate it!) +# it. For command line usage you use the `src/etc/cpu-usage-over-time-plot.sh` +# script in this repository. import datetime import sys 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 0000000000000..724a21c3fc269 --- /dev/null +++ b/src/etc/cpu-usage-over-time-plot.sh @@ -0,0 +1,49 @@ +#!/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 e699ea096fcc2fc9ce8e8bcf884e11496a31cc9f i686-mingw-1 +# +# 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! + +set -ex + +bucket=rust-lang-ci-evalazure +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.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